@@ -78,10 +78,20 @@ default Namespace upsertNamespaceMeta(
7878 @ SqlQuery ("SELECT * FROM namespaces ORDER BY name LIMIT :limit OFFSET :offset" )
7979 List <Namespace > findAll (int limit , int offset );
8080
81+ @ SqlUpdate ("UPDATE namespaces SET is_hidden=false WHERE name = :name" )
82+ void undelete (String name );
83+
84+ @ SqlUpdate ("UPDATE namespaces SET is_hidden=true WHERE name = :name" )
85+ void delete (String name );
86+
8187 default NamespaceRow upsertNamespaceRow (
8288 UUID uuid , Instant now , String name , String currentOwnerName ) {
8389 doUpsertNamespaceRow (uuid , now , name , currentOwnerName );
84- return findNamespaceByName (name ).orElseThrow ();
90+ NamespaceRow namespaceRow = findNamespaceByName (name ).orElseThrow ();
91+ if (namespaceRow .getIsHidden ()) {
92+ undelete (namespaceRow .getName ());
93+ }
94+ return namespaceRow ;
8595 }
8696
8797 /**
@@ -99,40 +109,47 @@ default NamespaceRow upsertNamespaceRow(
99109 * @param currentOwnerName
100110 */
101111 @ SqlUpdate (
102- "INSERT INTO namespaces ( "
103- + "uuid, "
104- + "created_at, "
105- + "updated_at, "
106- + "name, "
107- + "current_owner_name "
108- + ") VALUES ("
109- + ":uuid, "
110- + ":now, "
111- + ":now, "
112- + ":name, "
113- + ":currentOwnerName) "
114- + "ON CONFLICT(name) DO NOTHING" )
112+ """
113+ INSERT INTO namespaces (
114+ uuid,
115+ created_at,
116+ updated_at,
117+ name,
118+ current_owner_name
119+ ) VALUES (
120+ :uuid,
121+ :now,
122+ :now,
123+ :name,
124+ :currentOwnerName)
125+ ON CONFLICT(name) DO NOTHING
126+ """ )
115127 void doUpsertNamespaceRow (UUID uuid , Instant now , String name , String currentOwnerName );
116128
117129 @ SqlQuery (
118- "INSERT INTO namespaces ( "
119- + "uuid, "
120- + "created_at, "
121- + "updated_at, "
122- + "name, "
123- + "current_owner_name, "
124- + "description "
125- + ") VALUES ("
126- + ":uuid, "
127- + ":now, "
128- + ":now, "
129- + ":name, "
130- + ":currentOwnerName, "
131- + ":description "
132- + ") ON CONFLICT(name) DO "
133- + "UPDATE SET "
134- + "updated_at = EXCLUDED.updated_at "
135- + "RETURNING *" )
130+ """
131+ INSERT INTO namespaces (
132+ uuid,
133+ created_at,
134+ updated_at,
135+ name,
136+ current_owner_name,
137+ description,
138+ is_hidden
139+ ) VALUES (
140+ :uuid,
141+ :now,
142+ :now,
143+ :name,
144+ :currentOwnerName,
145+ :description,
146+ false
147+ ) ON CONFLICT(name) DO
148+ UPDATE SET
149+ updated_at = EXCLUDED.updated_at,
150+ is_hidden = false
151+ RETURNING *
152+ """ )
136153 NamespaceRow upsertNamespaceRow (
137154 UUID uuid , Instant now , String name , String currentOwnerName , String description );
138155
0 commit comments