From e364e31e25bd1d4b8d801c845a96d6be708f0a18 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 19 Jan 2023 09:27:16 +0100 Subject: Implement signup approval in server --- .../migrations/0750-user-registration.ts | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 server/initializers/migrations/0750-user-registration.ts (limited to 'server/initializers/migrations/0750-user-registration.ts') diff --git a/server/initializers/migrations/0750-user-registration.ts b/server/initializers/migrations/0750-user-registration.ts new file mode 100644 index 000000000..15bbfd3fd --- /dev/null +++ b/server/initializers/migrations/0750-user-registration.ts @@ -0,0 +1,58 @@ + +import * as Sequelize from 'sequelize' + +async function up (utils: { + transaction: Sequelize.Transaction + queryInterface: Sequelize.QueryInterface + sequelize: Sequelize.Sequelize + db: any +}): Promise { + { + const query = ` + CREATE TABLE IF NOT EXISTS "userRegistration" ( + "id" serial, + "state" integer NOT NULL, + "registrationReason" text NOT NULL, + "moderationResponse" text, + "password" varchar(255), + "username" varchar(255) NOT NULL, + "email" varchar(400) NOT NULL, + "emailVerified" boolean, + "accountDisplayName" varchar(255), + "channelHandle" varchar(255), + "channelDisplayName" varchar(255), + "userId" integer REFERENCES "user" ("id") ON DELETE SET NULL ON UPDATE CASCADE, + "createdAt" timestamp with time zone NOT NULL, + "updatedAt" timestamp with time zone NOT NULL, + PRIMARY KEY ("id") + ); + ` + await utils.sequelize.query(query, { transaction: utils.transaction }) + } + + { + await utils.queryInterface.addColumn('userNotification', 'userRegistrationId', { + type: Sequelize.INTEGER, + defaultValue: null, + allowNull: true, + references: { + model: 'userRegistration', + key: 'id' + }, + onUpdate: 'CASCADE', + onDelete: 'SET NULL' + }, { transaction: utils.transaction }) + } +} + +async function down (utils: { + queryInterface: Sequelize.QueryInterface + transaction: Sequelize.Transaction +}) { + await utils.queryInterface.dropTable('videoChannelSync', { transaction: utils.transaction }) +} + +export { + up, + down +} -- cgit v1.2.3