From c0a2e1b7ab182c90ff68b609bbadd5fdb6f9a63d Mon Sep 17 00:00:00 2001 From: Ben Allfree Date: Thu, 28 Dec 2023 08:47:18 -0800 Subject: [PATCH] Update cname to unique constraint while allowing empty --- .../1703774624_updated_instances.js | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/mothership-app/migrations/1703774624_updated_instances.js diff --git a/src/mothership-app/migrations/1703774624_updated_instances.js b/src/mothership-app/migrations/1703774624_updated_instances.js new file mode 100644 index 00000000..6ca5f404 --- /dev/null +++ b/src/mothership-app/migrations/1703774624_updated_instances.js @@ -0,0 +1,32 @@ +/// +migrate((db) => { + const dao = new Dao(db) + const collection = dao.findCollectionByNameOrId("etae8tuiaxl6xfv") + + collection.indexes = [ + "CREATE UNIQUE INDEX `idx_unique_qdtuuld1` ON `instances` (`subdomain`)", + "CREATE INDEX `idx_DKUSkMx` ON `instances` (`status`)", + "CREATE INDEX `idx_fhfKrpl` ON `instances` (`uid`)", + "CREATE INDEX `idx_TfdgNnO` ON `instances` (`maintenance`)", + "CREATE INDEX `idx_FrmHehp` ON `instances` (`created`)", + "CREATE INDEX `idx_tNMeylJ` ON `instances` (`updated`)", + "CREATE UNIQUE INDEX `idx_rBYwAXi` ON `instances` (`cname`) WHERE cname != ''" + ] + + return dao.saveCollection(collection) +}, (db) => { + const dao = new Dao(db) + const collection = dao.findCollectionByNameOrId("etae8tuiaxl6xfv") + + collection.indexes = [ + "CREATE UNIQUE INDEX `idx_unique_qdtuuld1` ON `instances` (`subdomain`)", + "CREATE INDEX `idx_DKUSkMx` ON `instances` (`status`)", + "CREATE INDEX `idx_fhfKrpl` ON `instances` (`uid`)", + "CREATE INDEX `idx_TfdgNnO` ON `instances` (`maintenance`)", + "CREATE INDEX `idx_FrmHehp` ON `instances` (`created`)", + "CREATE INDEX `idx_tNMeylJ` ON `instances` (`updated`)", + "CREATE INDEX `idx_rBYwAXi` ON `instances` (`cname`)" + ] + + return dao.saveCollection(collection) +})