From 4d9ed9ded29a2f8dbf3418f08e1bafab64b02eb3 Mon Sep 17 00:00:00 2001 From: Ben Allfree Date: Sun, 10 Nov 2024 17:44:52 -0800 Subject: [PATCH] enh: mothership user field validation --- .../1731248081_updated_subscribed_users.js | 178 +++++++++++ .../pb_migrations/1731248081_updated_users.js | 54 ++++ .../1731248081_updated_verified_users.js | 276 ++++++++++++++++++ 3 files changed, 508 insertions(+) create mode 100644 packages/pockethost/src/mothership-app/pb_migrations/1731248081_updated_subscribed_users.js create mode 100644 packages/pockethost/src/mothership-app/pb_migrations/1731248081_updated_users.js create mode 100644 packages/pockethost/src/mothership-app/pb_migrations/1731248081_updated_verified_users.js diff --git a/packages/pockethost/src/mothership-app/pb_migrations/1731248081_updated_subscribed_users.js b/packages/pockethost/src/mothership-app/pb_migrations/1731248081_updated_subscribed_users.js new file mode 100644 index 00000000..8926125f --- /dev/null +++ b/packages/pockethost/src/mothership-app/pb_migrations/1731248081_updated_subscribed_users.js @@ -0,0 +1,178 @@ +/// +migrate((db) => { + const dao = new Dao(db) + const collection = dao.findCollectionByNameOrId("s00x84jumfjcuvc") + + // remove + collection.schema.removeField("nxduzx8j") + + // remove + collection.schema.removeField("uxypjefe") + + // remove + collection.schema.removeField("2eksisrf") + + // remove + collection.schema.removeField("9vsfyoqa") + + // add + collection.schema.addField(new SchemaField({ + "system": false, + "id": "kij3qt2u", + "name": "username", + "type": "text", + "required": false, + "presentable": false, + "unique": false, + "options": { + "min": null, + "max": null, + "pattern": "" + } + })) + + // add + collection.schema.addField(new SchemaField({ + "system": false, + "id": "cwdyzhim", + "name": "email", + "type": "email", + "required": false, + "presentable": false, + "unique": false, + "options": { + "exceptDomains": null, + "onlyDomains": null + } + })) + + // add + collection.schema.addField(new SchemaField({ + "system": false, + "id": "ou52evzg", + "name": "subscription", + "type": "select", + "required": true, + "presentable": false, + "unique": false, + "options": { + "maxSelect": 1, + "values": [ + "free", + "premium", + "founder", + "flounder", + "legacy" + ] + } + })) + + // add + collection.schema.addField(new SchemaField({ + "system": false, + "id": "shuxbcrz", + "name": "subscription_interval", + "type": "select", + "required": false, + "presentable": false, + "unique": false, + "options": { + "maxSelect": 1, + "values": [ + "month", + "year", + "life" + ] + } + })) + + return dao.saveCollection(collection) +}, (db) => { + const dao = new Dao(db) + const collection = dao.findCollectionByNameOrId("s00x84jumfjcuvc") + + // add + collection.schema.addField(new SchemaField({ + "system": false, + "id": "nxduzx8j", + "name": "username", + "type": "text", + "required": false, + "presentable": false, + "unique": false, + "options": { + "min": null, + "max": null, + "pattern": "" + } + })) + + // add + collection.schema.addField(new SchemaField({ + "system": false, + "id": "uxypjefe", + "name": "email", + "type": "email", + "required": false, + "presentable": false, + "unique": false, + "options": { + "exceptDomains": null, + "onlyDomains": null + } + })) + + // add + collection.schema.addField(new SchemaField({ + "system": false, + "id": "2eksisrf", + "name": "subscription", + "type": "select", + "required": true, + "presentable": false, + "unique": false, + "options": { + "maxSelect": 1, + "values": [ + "free", + "premium", + "lifetime", + "founder", + "legacy" + ] + } + })) + + // add + collection.schema.addField(new SchemaField({ + "system": false, + "id": "9vsfyoqa", + "name": "subscription_interval", + "type": "select", + "required": false, + "presentable": false, + "unique": false, + "options": { + "maxSelect": 1, + "values": [ + "month", + "year", + "life" + ] + } + })) + + // remove + collection.schema.removeField("kij3qt2u") + + // remove + collection.schema.removeField("cwdyzhim") + + // remove + collection.schema.removeField("ou52evzg") + + // remove + collection.schema.removeField("shuxbcrz") + + return dao.saveCollection(collection) +}) diff --git a/packages/pockethost/src/mothership-app/pb_migrations/1731248081_updated_users.js b/packages/pockethost/src/mothership-app/pb_migrations/1731248081_updated_users.js new file mode 100644 index 00000000..76ee04d8 --- /dev/null +++ b/packages/pockethost/src/mothership-app/pb_migrations/1731248081_updated_users.js @@ -0,0 +1,54 @@ +/// +migrate((db) => { + const dao = new Dao(db) + const collection = dao.findCollectionByNameOrId("systemprofiles0") + + // update + collection.schema.addField(new SchemaField({ + "system": false, + "id": "7jf2i4be", + "name": "subscription", + "type": "select", + "required": true, + "presentable": false, + "unique": false, + "options": { + "maxSelect": 1, + "values": [ + "free", + "premium", + "founder", + "flounder", + "legacy" + ] + } + })) + + return dao.saveCollection(collection) +}, (db) => { + const dao = new Dao(db) + const collection = dao.findCollectionByNameOrId("systemprofiles0") + + // update + collection.schema.addField(new SchemaField({ + "system": false, + "id": "7jf2i4be", + "name": "subscription", + "type": "select", + "required": true, + "presentable": false, + "unique": false, + "options": { + "maxSelect": 1, + "values": [ + "free", + "premium", + "lifetime", + "founder", + "legacy" + ] + } + })) + + return dao.saveCollection(collection) +}) diff --git a/packages/pockethost/src/mothership-app/pb_migrations/1731248081_updated_verified_users.js b/packages/pockethost/src/mothership-app/pb_migrations/1731248081_updated_verified_users.js new file mode 100644 index 00000000..0bc16713 --- /dev/null +++ b/packages/pockethost/src/mothership-app/pb_migrations/1731248081_updated_verified_users.js @@ -0,0 +1,276 @@ +/// +migrate((db) => { + const dao = new Dao(db) + const collection = dao.findCollectionByNameOrId("4kshuv7r3jdrst4") + + // remove + collection.schema.removeField("fec2cbfb") + + // remove + collection.schema.removeField("tytnadtb") + + // remove + collection.schema.removeField("juickogz") + + // remove + collection.schema.removeField("e5tbaqub") + + // remove + collection.schema.removeField("lzoyncmi") + + // remove + collection.schema.removeField("p5hwwwd1") + + // remove + collection.schema.removeField("mswqajfw") + + // add + collection.schema.addField(new SchemaField({ + "system": false, + "id": "lgcb0lnr", + "name": "username", + "type": "text", + "required": false, + "presentable": false, + "unique": false, + "options": { + "min": null, + "max": null, + "pattern": "" + } + })) + + // add + collection.schema.addField(new SchemaField({ + "system": false, + "id": "uis8woxw", + "name": "email", + "type": "email", + "required": false, + "presentable": false, + "unique": false, + "options": { + "exceptDomains": null, + "onlyDomains": null + } + })) + + // add + collection.schema.addField(new SchemaField({ + "system": false, + "id": "6dbuvkcr", + "name": "subscription", + "type": "select", + "required": true, + "presentable": false, + "unique": false, + "options": { + "maxSelect": 1, + "values": [ + "free", + "premium", + "founder", + "flounder", + "legacy" + ] + } + })) + + // add + collection.schema.addField(new SchemaField({ + "system": false, + "id": "nrmbdf15", + "name": "subscription_interval", + "type": "select", + "required": false, + "presentable": false, + "unique": false, + "options": { + "maxSelect": 1, + "values": [ + "month", + "year", + "life" + ] + } + })) + + // add + collection.schema.addField(new SchemaField({ + "system": false, + "id": "bjws5smi", + "name": "tokenKey", + "type": "json", + "required": false, + "presentable": false, + "unique": false, + "options": { + "maxSize": 1 + } + })) + + // add + collection.schema.addField(new SchemaField({ + "system": false, + "id": "dlh0pf9o", + "name": "passwordHash", + "type": "json", + "required": false, + "presentable": false, + "unique": false, + "options": { + "maxSize": 1 + } + })) + + // add + collection.schema.addField(new SchemaField({ + "system": false, + "id": "baky64ne", + "name": "unsubscribe", + "type": "bool", + "required": false, + "presentable": false, + "unique": false, + "options": {} + })) + + return dao.saveCollection(collection) +}, (db) => { + const dao = new Dao(db) + const collection = dao.findCollectionByNameOrId("4kshuv7r3jdrst4") + + // add + collection.schema.addField(new SchemaField({ + "system": false, + "id": "fec2cbfb", + "name": "username", + "type": "text", + "required": false, + "presentable": false, + "unique": false, + "options": { + "min": null, + "max": null, + "pattern": "" + } + })) + + // add + collection.schema.addField(new SchemaField({ + "system": false, + "id": "tytnadtb", + "name": "email", + "type": "email", + "required": false, + "presentable": false, + "unique": false, + "options": { + "exceptDomains": null, + "onlyDomains": null + } + })) + + // add + collection.schema.addField(new SchemaField({ + "system": false, + "id": "juickogz", + "name": "subscription", + "type": "select", + "required": true, + "presentable": false, + "unique": false, + "options": { + "maxSelect": 1, + "values": [ + "free", + "premium", + "lifetime", + "founder", + "legacy" + ] + } + })) + + // add + collection.schema.addField(new SchemaField({ + "system": false, + "id": "e5tbaqub", + "name": "subscription_interval", + "type": "select", + "required": false, + "presentable": false, + "unique": false, + "options": { + "maxSelect": 1, + "values": [ + "month", + "year", + "life" + ] + } + })) + + // add + collection.schema.addField(new SchemaField({ + "system": false, + "id": "lzoyncmi", + "name": "tokenKey", + "type": "json", + "required": false, + "presentable": false, + "unique": false, + "options": { + "maxSize": 1 + } + })) + + // add + collection.schema.addField(new SchemaField({ + "system": false, + "id": "p5hwwwd1", + "name": "passwordHash", + "type": "json", + "required": false, + "presentable": false, + "unique": false, + "options": { + "maxSize": 1 + } + })) + + // add + collection.schema.addField(new SchemaField({ + "system": false, + "id": "mswqajfw", + "name": "unsubscribe", + "type": "bool", + "required": false, + "presentable": false, + "unique": false, + "options": {} + })) + + // remove + collection.schema.removeField("lgcb0lnr") + + // remove + collection.schema.removeField("uis8woxw") + + // remove + collection.schema.removeField("6dbuvkcr") + + // remove + collection.schema.removeField("nrmbdf15") + + // remove + collection.schema.removeField("bjws5smi") + + // remove + collection.schema.removeField("dlh0pf9o") + + // remove + collection.schema.removeField("baky64ne") + + return dao.saveCollection(collection) +})