diff PostgreSQL/Plugins/PostgreSQLIndex.cpp @ 396:7b3acfa95bd8 db-protobuf

implementation of list/add/remove labels in postgresql
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 06 Apr 2023 19:00:29 +0200
parents 3d6886f3e5b3
children 91124cc8a8c7
line wrap: on
line diff
--- a/PostgreSQL/Plugins/PostgreSQLIndex.cpp	Wed Apr 05 14:53:57 2023 +0200
+++ b/PostgreSQL/Plugins/PostgreSQLIndex.cpp	Thu Apr 06 19:00:29 2023 +0200
@@ -297,6 +297,24 @@
 
         t.Commit();
       }
+ 
+
+      {
+        // New in release 5.0 to deal with labels
+        DatabaseManager::Transaction t(manager, TransactionType_ReadWrite);
+
+        if (!t.GetDatabaseTransaction().DoesTableExist("Labels"))
+        {
+          t.GetDatabaseTransaction().ExecuteMultiLines(
+            "CREATE TABLE Labels("
+            "id BIGINT REFERENCES Resources(internalId) ON DELETE CASCADE,"
+            "label TEXT, PRIMARY KEY(id, label));"
+            "CREATE INDEX LabelsIndex1 ON LABELS(id);"
+            "CREATE INDEX LabelsIndex2 ON LABELS(label);");
+        }
+
+        t.Commit();
+      }
     }
   }