"use strict"; module.exports = { up: async (queryInterface, Sequelize) => { await queryInterface.createTable("AlphaInvitations", { id: { type: Sequelize.UUID, defaultValue: Sequelize.UUIDV4, primaryKey: true, }, code: { type: Sequelize.STRING, unique: true, allowNull: false, }, email: { type: Sequelize.STRING, unique: true, allowNull: false, }, status: { type: Sequelize.ENUM("pending", "active", "revoked"), defaultValue: "pending", }, usedBy: { type: Sequelize.UUID, allowNull: true, references: { model: "Users", key: "id", }, onUpdate: "CASCADE", onDelete: "SET NULL", }, usedAt: { type: Sequelize.DATE, allowNull: true, }, createdAt: { type: Sequelize.DATE, allowNull: false, }, updatedAt: { type: Sequelize.DATE, allowNull: false, }, }); // Add indexes await queryInterface.addIndex("AlphaInvitations", ["code"], { unique: true, }); await queryInterface.addIndex("AlphaInvitations", ["email"]); await queryInterface.addIndex("AlphaInvitations", ["status"]); }, down: async (queryInterface, Sequelize) => { await queryInterface.dropTable("AlphaInvitations"); }, };