mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-12-23 00:03:09 +02:00
feat: database migrations
This commit is contained in:
parent
457ede3ac7
commit
63f5ea61f7
257
db/mysql/migrations/20230130211315_4_0_0/migration.sql
Normal file
257
db/mysql/migrations/20230130211315_4_0_0/migration.sql
Normal file
@ -0,0 +1,257 @@
|
|||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE `archivedChannels` (
|
||||||
|
`channelId` VARCHAR(19) NOT NULL,
|
||||||
|
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||||
|
`name` VARCHAR(191) NOT NULL,
|
||||||
|
`ticketId` VARCHAR(19) NOT NULL,
|
||||||
|
|
||||||
|
UNIQUE INDEX `archivedChannels_ticketId_channelId_key`(`ticketId`, `channelId`),
|
||||||
|
PRIMARY KEY (`ticketId`, `channelId`)
|
||||||
|
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE `archivedMessages` (
|
||||||
|
`authorId` VARCHAR(19) NOT NULL,
|
||||||
|
`content` TEXT NOT NULL,
|
||||||
|
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||||
|
`deleted` BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
`edited` BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
`external` BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
`id` VARCHAR(19) NOT NULL,
|
||||||
|
`ticketId` VARCHAR(19) NOT NULL,
|
||||||
|
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE `archivedRoles` (
|
||||||
|
`colour` CHAR(6) NOT NULL DEFAULT '5865F2',
|
||||||
|
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||||
|
`name` VARCHAR(191) NOT NULL,
|
||||||
|
`roleId` VARCHAR(19) NOT NULL,
|
||||||
|
`ticketId` VARCHAR(19) NOT NULL,
|
||||||
|
|
||||||
|
UNIQUE INDEX `archivedRoles_ticketId_roleId_key`(`ticketId`, `roleId`),
|
||||||
|
PRIMARY KEY (`ticketId`, `roleId`)
|
||||||
|
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE `archivedUsers` (
|
||||||
|
`avatar` VARCHAR(191) NULL,
|
||||||
|
`bot` BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||||
|
`discriminator` CHAR(4) NULL,
|
||||||
|
`displayName` TEXT NULL,
|
||||||
|
`roleId` VARCHAR(19) NULL,
|
||||||
|
`ticketId` VARCHAR(19) NOT NULL,
|
||||||
|
`userId` VARCHAR(19) NOT NULL,
|
||||||
|
`username` TEXT NULL,
|
||||||
|
|
||||||
|
UNIQUE INDEX `archivedUsers_ticketId_userId_key`(`ticketId`, `userId`),
|
||||||
|
PRIMARY KEY (`ticketId`, `userId`)
|
||||||
|
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE `categories` (
|
||||||
|
`channelName` VARCHAR(191) NOT NULL,
|
||||||
|
`claiming` BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||||
|
`cooldown` INTEGER NULL,
|
||||||
|
`customTopic` VARCHAR(191) NULL,
|
||||||
|
`description` VARCHAR(191) NOT NULL,
|
||||||
|
`discordCategory` VARCHAR(19) NOT NULL,
|
||||||
|
`emoji` VARCHAR(191) NOT NULL,
|
||||||
|
`enableFeedback` BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
`guildId` VARCHAR(19) NOT NULL,
|
||||||
|
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||||
|
`image` VARCHAR(191) NULL,
|
||||||
|
`memberLimit` INTEGER NOT NULL DEFAULT 1,
|
||||||
|
`name` VARCHAR(191) NOT NULL,
|
||||||
|
`openingMessage` TEXT NOT NULL,
|
||||||
|
`pingRoles` JSON NOT NULL,
|
||||||
|
`ratelimit` INTEGER NULL,
|
||||||
|
`requiredRoles` JSON NOT NULL,
|
||||||
|
`requireTopic` BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
`staffRoles` JSON NOT NULL,
|
||||||
|
`totalLimit` INTEGER NOT NULL DEFAULT 50,
|
||||||
|
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE `feedback` (
|
||||||
|
`comment` TEXT NULL,
|
||||||
|
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||||
|
`guildId` VARCHAR(19) NOT NULL,
|
||||||
|
`rating` INTEGER NOT NULL,
|
||||||
|
`ticketId` VARCHAR(19) NOT NULL,
|
||||||
|
`userId` VARCHAR(19) NULL,
|
||||||
|
|
||||||
|
PRIMARY KEY (`ticketId`)
|
||||||
|
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE `guilds` (
|
||||||
|
`autoClose` INTEGER NOT NULL DEFAULT 43200000,
|
||||||
|
`autoTag` JSON NOT NULL,
|
||||||
|
`archive` BOOLEAN NOT NULL DEFAULT true,
|
||||||
|
`blocklist` JSON NOT NULL,
|
||||||
|
`claimButton` BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
`closeButton` BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||||
|
`errorColour` VARCHAR(191) NOT NULL DEFAULT 'Red',
|
||||||
|
`footer` VARCHAR(191) NULL DEFAULT 'Discord Tickets by eartharoid',
|
||||||
|
`id` VARCHAR(19) NOT NULL,
|
||||||
|
`locale` VARCHAR(191) NOT NULL DEFAULT 'en-GB',
|
||||||
|
`logChannel` VARCHAR(19) NULL,
|
||||||
|
`primaryColour` VARCHAR(191) NOT NULL DEFAULT '#009999',
|
||||||
|
`staleAfter` INTEGER NULL,
|
||||||
|
`successColour` VARCHAR(191) NOT NULL DEFAULT 'Green',
|
||||||
|
`workingHours` JSON NOT NULL,
|
||||||
|
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE `questions` (
|
||||||
|
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||||
|
`id` VARCHAR(191) NOT NULL,
|
||||||
|
`categoryId` INTEGER NOT NULL,
|
||||||
|
`label` VARCHAR(45) NOT NULL,
|
||||||
|
`maxLength` INTEGER NULL DEFAULT 4000,
|
||||||
|
`minLength` INTEGER NULL DEFAULT 0,
|
||||||
|
`options` JSON NOT NULL,
|
||||||
|
`order` INTEGER NOT NULL,
|
||||||
|
`placeholder` VARCHAR(100) NULL,
|
||||||
|
`required` BOOLEAN NOT NULL DEFAULT true,
|
||||||
|
`style` INTEGER NOT NULL DEFAULT 2,
|
||||||
|
`type` ENUM('MENU', 'TEXT') NOT NULL DEFAULT 'TEXT',
|
||||||
|
`value` TEXT NULL,
|
||||||
|
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE `questionAnswers` (
|
||||||
|
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||||
|
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||||
|
`ticketId` VARCHAR(19) NOT NULL,
|
||||||
|
`questionId` VARCHAR(191) NOT NULL,
|
||||||
|
`userId` VARCHAR(19) NOT NULL,
|
||||||
|
`value` TEXT NULL,
|
||||||
|
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE `tags` (
|
||||||
|
`content` TEXT NOT NULL,
|
||||||
|
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||||
|
`guildId` VARCHAR(19) NOT NULL,
|
||||||
|
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||||
|
`name` VARCHAR(191) NOT NULL,
|
||||||
|
`regex` VARCHAR(191) NULL,
|
||||||
|
|
||||||
|
UNIQUE INDEX `tags_guildId_name_key`(`guildId`, `name`),
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE `tickets` (
|
||||||
|
`categoryId` INTEGER NULL,
|
||||||
|
`claimedById` VARCHAR(19) NULL,
|
||||||
|
`closedAt` DATETIME(3) NULL,
|
||||||
|
`closedById` VARCHAR(19) NULL,
|
||||||
|
`closedReason` TEXT NULL,
|
||||||
|
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||||
|
`createdById` VARCHAR(19) NOT NULL,
|
||||||
|
`deleted` BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
`firstResponseAt` DATETIME(3) NULL,
|
||||||
|
`guildId` VARCHAR(19) NOT NULL,
|
||||||
|
`id` VARCHAR(19) NOT NULL,
|
||||||
|
`lastMessageAt` DATETIME(3) NULL,
|
||||||
|
`messageCount` INTEGER NULL,
|
||||||
|
`number` INTEGER NOT NULL,
|
||||||
|
`open` BOOLEAN NOT NULL DEFAULT true,
|
||||||
|
`openingMessageId` VARCHAR(19) NOT NULL,
|
||||||
|
`pinnedMessageIds` JSON NOT NULL,
|
||||||
|
`priority` ENUM('LOW', 'MEDIUM', 'HIGH') NULL,
|
||||||
|
`referencesMessageId` VARCHAR(19) NULL,
|
||||||
|
`referencesTicketId` VARCHAR(19) NULL,
|
||||||
|
`topic` TEXT NULL,
|
||||||
|
|
||||||
|
UNIQUE INDEX `tickets_guildId_number_key`(`guildId`, `number`),
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE `users` (
|
||||||
|
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||||
|
`id` VARCHAR(19) NOT NULL,
|
||||||
|
`messageCount` INTEGER NOT NULL DEFAULT 0,
|
||||||
|
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE `archivedChannels` ADD CONSTRAINT `archivedChannels_ticketId_fkey` FOREIGN KEY (`ticketId`) REFERENCES `tickets`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE `archivedMessages` ADD CONSTRAINT `archivedMessages_ticketId_authorId_fkey` FOREIGN KEY (`ticketId`, `authorId`) REFERENCES `archivedUsers`(`ticketId`, `userId`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE `archivedMessages` ADD CONSTRAINT `archivedMessages_ticketId_fkey` FOREIGN KEY (`ticketId`) REFERENCES `tickets`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE `archivedRoles` ADD CONSTRAINT `archivedRoles_ticketId_fkey` FOREIGN KEY (`ticketId`) REFERENCES `tickets`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE `archivedUsers` ADD CONSTRAINT `archivedUsers_ticketId_roleId_fkey` FOREIGN KEY (`ticketId`, `roleId`) REFERENCES `archivedRoles`(`ticketId`, `roleId`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE `archivedUsers` ADD CONSTRAINT `archivedUsers_ticketId_fkey` FOREIGN KEY (`ticketId`) REFERENCES `tickets`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE `categories` ADD CONSTRAINT `categories_guildId_fkey` FOREIGN KEY (`guildId`) REFERENCES `guilds`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE `feedback` ADD CONSTRAINT `feedback_guildId_fkey` FOREIGN KEY (`guildId`) REFERENCES `guilds`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE `feedback` ADD CONSTRAINT `feedback_ticketId_fkey` FOREIGN KEY (`ticketId`) REFERENCES `tickets`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE `feedback` ADD CONSTRAINT `feedback_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `users`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE `questions` ADD CONSTRAINT `questions_categoryId_fkey` FOREIGN KEY (`categoryId`) REFERENCES `categories`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE `questionAnswers` ADD CONSTRAINT `questionAnswers_ticketId_fkey` FOREIGN KEY (`ticketId`) REFERENCES `tickets`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE `questionAnswers` ADD CONSTRAINT `questionAnswers_questionId_fkey` FOREIGN KEY (`questionId`) REFERENCES `questions`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE `questionAnswers` ADD CONSTRAINT `questionAnswers_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `users`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE `tags` ADD CONSTRAINT `tags_guildId_fkey` FOREIGN KEY (`guildId`) REFERENCES `guilds`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE `tickets` ADD CONSTRAINT `tickets_categoryId_fkey` FOREIGN KEY (`categoryId`) REFERENCES `categories`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE `tickets` ADD CONSTRAINT `tickets_claimedById_fkey` FOREIGN KEY (`claimedById`) REFERENCES `users`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE `tickets` ADD CONSTRAINT `tickets_closedById_fkey` FOREIGN KEY (`closedById`) REFERENCES `users`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE `tickets` ADD CONSTRAINT `tickets_createdById_fkey` FOREIGN KEY (`createdById`) REFERENCES `users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE `tickets` ADD CONSTRAINT `tickets_guildId_fkey` FOREIGN KEY (`guildId`) REFERENCES `guilds`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE `tickets` ADD CONSTRAINT `tickets_referencesTicketId_fkey` FOREIGN KEY (`referencesTicketId`) REFERENCES `tickets`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
3
db/mysql/migrations/migration_lock.toml
Normal file
3
db/mysql/migrations/migration_lock.toml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Please do not edit this file manually
|
||||||
|
# It should be added in your version-control system (i.e. Git)
|
||||||
|
provider = "mysql"
|
@ -5,6 +5,7 @@ generator client {
|
|||||||
datasource db {
|
datasource db {
|
||||||
provider = "mysql"
|
provider = "mysql"
|
||||||
url = env("DB_CONNECTION_URL")
|
url = env("DB_CONNECTION_URL")
|
||||||
|
shadowDatabaseUrl = env("SHADOW_DATABASE_URL")
|
||||||
}
|
}
|
||||||
|
|
||||||
model ArchivedChannel {
|
model ArchivedChannel {
|
||||||
|
273
db/postgresql/migrations/20230130210021_4_0_0/migration.sql
Normal file
273
db/postgresql/migrations/20230130210021_4_0_0/migration.sql
Normal file
@ -0,0 +1,273 @@
|
|||||||
|
-- CreateEnum
|
||||||
|
CREATE TYPE "TicketPriority" AS ENUM ('LOW', 'MEDIUM', 'HIGH');
|
||||||
|
|
||||||
|
-- CreateEnum
|
||||||
|
CREATE TYPE "QuestionType" AS ENUM ('MENU', 'TEXT');
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "archivedChannels" (
|
||||||
|
"channelId" VARCHAR(19) NOT NULL,
|
||||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"name" TEXT NOT NULL,
|
||||||
|
"ticketId" VARCHAR(19) NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "archivedChannels_pkey" PRIMARY KEY ("ticketId","channelId")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "archivedMessages" (
|
||||||
|
"authorId" VARCHAR(19) NOT NULL,
|
||||||
|
"content" TEXT NOT NULL,
|
||||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"deleted" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"edited" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"external" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"id" VARCHAR(19) NOT NULL,
|
||||||
|
"ticketId" VARCHAR(19) NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "archivedMessages_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "archivedRoles" (
|
||||||
|
"colour" CHAR(6) NOT NULL DEFAULT '5865F2',
|
||||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"name" TEXT NOT NULL,
|
||||||
|
"roleId" VARCHAR(19) NOT NULL,
|
||||||
|
"ticketId" VARCHAR(19) NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "archivedRoles_pkey" PRIMARY KEY ("ticketId","roleId")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "archivedUsers" (
|
||||||
|
"avatar" TEXT,
|
||||||
|
"bot" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"discriminator" CHAR(4),
|
||||||
|
"displayName" TEXT,
|
||||||
|
"roleId" VARCHAR(19),
|
||||||
|
"ticketId" VARCHAR(19) NOT NULL,
|
||||||
|
"userId" VARCHAR(19) NOT NULL,
|
||||||
|
"username" TEXT,
|
||||||
|
|
||||||
|
CONSTRAINT "archivedUsers_pkey" PRIMARY KEY ("ticketId","userId")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "categories" (
|
||||||
|
"channelName" TEXT NOT NULL,
|
||||||
|
"claiming" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"cooldown" INTEGER,
|
||||||
|
"customTopic" TEXT,
|
||||||
|
"description" TEXT NOT NULL,
|
||||||
|
"discordCategory" VARCHAR(19) NOT NULL,
|
||||||
|
"emoji" TEXT NOT NULL,
|
||||||
|
"enableFeedback" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"guildId" VARCHAR(19) NOT NULL,
|
||||||
|
"id" SERIAL NOT NULL,
|
||||||
|
"image" TEXT,
|
||||||
|
"memberLimit" INTEGER NOT NULL DEFAULT 1,
|
||||||
|
"name" TEXT NOT NULL,
|
||||||
|
"openingMessage" TEXT NOT NULL,
|
||||||
|
"pingRoles" JSONB NOT NULL DEFAULT '[]',
|
||||||
|
"ratelimit" INTEGER,
|
||||||
|
"requiredRoles" JSONB NOT NULL DEFAULT '[]',
|
||||||
|
"requireTopic" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"staffRoles" JSONB NOT NULL,
|
||||||
|
"totalLimit" INTEGER NOT NULL DEFAULT 50,
|
||||||
|
|
||||||
|
CONSTRAINT "categories_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "feedback" (
|
||||||
|
"comment" TEXT,
|
||||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"guildId" VARCHAR(19) NOT NULL,
|
||||||
|
"rating" INTEGER NOT NULL,
|
||||||
|
"ticketId" VARCHAR(19) NOT NULL,
|
||||||
|
"userId" VARCHAR(19),
|
||||||
|
|
||||||
|
CONSTRAINT "feedback_pkey" PRIMARY KEY ("ticketId")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "guilds" (
|
||||||
|
"autoClose" INTEGER NOT NULL DEFAULT 43200000,
|
||||||
|
"autoTag" JSONB NOT NULL DEFAULT '[]',
|
||||||
|
"archive" BOOLEAN NOT NULL DEFAULT true,
|
||||||
|
"blocklist" JSONB NOT NULL DEFAULT '[]',
|
||||||
|
"claimButton" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"closeButton" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"errorColour" TEXT NOT NULL DEFAULT 'Red',
|
||||||
|
"footer" TEXT DEFAULT 'Discord Tickets by eartharoid',
|
||||||
|
"id" VARCHAR(19) NOT NULL,
|
||||||
|
"locale" TEXT NOT NULL DEFAULT 'en-GB',
|
||||||
|
"logChannel" VARCHAR(19),
|
||||||
|
"primaryColour" TEXT NOT NULL DEFAULT '#009999',
|
||||||
|
"staleAfter" INTEGER,
|
||||||
|
"successColour" TEXT NOT NULL DEFAULT 'Green',
|
||||||
|
"workingHours" JSONB NOT NULL DEFAULT '["UTC", ["00:00","23:59"], ["00:00","23:59"], ["00:00","23:59"], ["00:00","23:59"], ["00:00","23:59"], ["00:00","23:59"], ["00:00","23:59"]]',
|
||||||
|
|
||||||
|
CONSTRAINT "guilds_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "questions" (
|
||||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"categoryId" INTEGER NOT NULL,
|
||||||
|
"label" VARCHAR(45) NOT NULL,
|
||||||
|
"maxLength" INTEGER DEFAULT 4000,
|
||||||
|
"minLength" INTEGER DEFAULT 0,
|
||||||
|
"options" JSONB NOT NULL DEFAULT '[]',
|
||||||
|
"order" INTEGER NOT NULL,
|
||||||
|
"placeholder" VARCHAR(100),
|
||||||
|
"required" BOOLEAN NOT NULL DEFAULT true,
|
||||||
|
"style" INTEGER NOT NULL DEFAULT 2,
|
||||||
|
"type" "QuestionType" NOT NULL DEFAULT 'TEXT',
|
||||||
|
"value" TEXT,
|
||||||
|
|
||||||
|
CONSTRAINT "questions_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "questionAnswers" (
|
||||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"id" SERIAL NOT NULL,
|
||||||
|
"ticketId" VARCHAR(19) NOT NULL,
|
||||||
|
"questionId" TEXT NOT NULL,
|
||||||
|
"userId" VARCHAR(19) NOT NULL,
|
||||||
|
"value" TEXT,
|
||||||
|
|
||||||
|
CONSTRAINT "questionAnswers_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "tags" (
|
||||||
|
"content" TEXT NOT NULL,
|
||||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"guildId" VARCHAR(19) NOT NULL,
|
||||||
|
"id" SERIAL NOT NULL,
|
||||||
|
"name" TEXT NOT NULL,
|
||||||
|
"regex" TEXT,
|
||||||
|
|
||||||
|
CONSTRAINT "tags_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "tickets" (
|
||||||
|
"categoryId" INTEGER,
|
||||||
|
"claimedById" VARCHAR(19),
|
||||||
|
"closedAt" TIMESTAMP(3),
|
||||||
|
"closedById" VARCHAR(19),
|
||||||
|
"closedReason" TEXT,
|
||||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"createdById" VARCHAR(19) NOT NULL,
|
||||||
|
"deleted" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"firstResponseAt" TIMESTAMP(3),
|
||||||
|
"guildId" VARCHAR(19) NOT NULL,
|
||||||
|
"id" VARCHAR(19) NOT NULL,
|
||||||
|
"lastMessageAt" TIMESTAMP(3),
|
||||||
|
"messageCount" INTEGER,
|
||||||
|
"number" INTEGER NOT NULL,
|
||||||
|
"open" BOOLEAN NOT NULL DEFAULT true,
|
||||||
|
"openingMessageId" VARCHAR(19) NOT NULL,
|
||||||
|
"pinnedMessageIds" JSONB NOT NULL DEFAULT '[]',
|
||||||
|
"priority" "TicketPriority",
|
||||||
|
"referencesMessageId" VARCHAR(19),
|
||||||
|
"referencesTicketId" VARCHAR(19),
|
||||||
|
"topic" TEXT,
|
||||||
|
|
||||||
|
CONSTRAINT "tickets_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "users" (
|
||||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"id" VARCHAR(19) NOT NULL,
|
||||||
|
"messageCount" INTEGER NOT NULL DEFAULT 0,
|
||||||
|
|
||||||
|
CONSTRAINT "users_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "archivedChannels_ticketId_channelId_key" ON "archivedChannels"("ticketId", "channelId");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "archivedRoles_ticketId_roleId_key" ON "archivedRoles"("ticketId", "roleId");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "archivedUsers_ticketId_userId_key" ON "archivedUsers"("ticketId", "userId");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "tags_guildId_name_key" ON "tags"("guildId", "name");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "tickets_guildId_number_key" ON "tickets"("guildId", "number");
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "archivedChannels" ADD CONSTRAINT "archivedChannels_ticketId_fkey" FOREIGN KEY ("ticketId") REFERENCES "tickets"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "archivedMessages" ADD CONSTRAINT "archivedMessages_ticketId_authorId_fkey" FOREIGN KEY ("ticketId", "authorId") REFERENCES "archivedUsers"("ticketId", "userId") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "archivedMessages" ADD CONSTRAINT "archivedMessages_ticketId_fkey" FOREIGN KEY ("ticketId") REFERENCES "tickets"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "archivedRoles" ADD CONSTRAINT "archivedRoles_ticketId_fkey" FOREIGN KEY ("ticketId") REFERENCES "tickets"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "archivedUsers" ADD CONSTRAINT "archivedUsers_ticketId_roleId_fkey" FOREIGN KEY ("ticketId", "roleId") REFERENCES "archivedRoles"("ticketId", "roleId") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "archivedUsers" ADD CONSTRAINT "archivedUsers_ticketId_fkey" FOREIGN KEY ("ticketId") REFERENCES "tickets"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "categories" ADD CONSTRAINT "categories_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "guilds"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "feedback" ADD CONSTRAINT "feedback_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "guilds"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "feedback" ADD CONSTRAINT "feedback_ticketId_fkey" FOREIGN KEY ("ticketId") REFERENCES "tickets"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "feedback" ADD CONSTRAINT "feedback_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "questions" ADD CONSTRAINT "questions_categoryId_fkey" FOREIGN KEY ("categoryId") REFERENCES "categories"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "questionAnswers" ADD CONSTRAINT "questionAnswers_ticketId_fkey" FOREIGN KEY ("ticketId") REFERENCES "tickets"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "questionAnswers" ADD CONSTRAINT "questionAnswers_questionId_fkey" FOREIGN KEY ("questionId") REFERENCES "questions"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "questionAnswers" ADD CONSTRAINT "questionAnswers_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "tags" ADD CONSTRAINT "tags_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "guilds"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "tickets" ADD CONSTRAINT "tickets_categoryId_fkey" FOREIGN KEY ("categoryId") REFERENCES "categories"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "tickets" ADD CONSTRAINT "tickets_claimedById_fkey" FOREIGN KEY ("claimedById") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "tickets" ADD CONSTRAINT "tickets_closedById_fkey" FOREIGN KEY ("closedById") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "tickets" ADD CONSTRAINT "tickets_createdById_fkey" FOREIGN KEY ("createdById") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "tickets" ADD CONSTRAINT "tickets_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "guilds"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "tickets" ADD CONSTRAINT "tickets_referencesTicketId_fkey" FOREIGN KEY ("referencesTicketId") REFERENCES "tickets"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
3
db/postgresql/migrations/migration_lock.toml
Normal file
3
db/postgresql/migrations/migration_lock.toml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Please do not edit this file manually
|
||||||
|
# It should be added in your version-control system (i.e. Git)
|
||||||
|
provider = "postgresql"
|
207
db/sqlite/migrations/20230130211842_4_0_0/migration.sql
Normal file
207
db/sqlite/migrations/20230130211842_4_0_0/migration.sql
Normal file
@ -0,0 +1,207 @@
|
|||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "archivedChannels" (
|
||||||
|
"channelId" TEXT NOT NULL,
|
||||||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"name" TEXT NOT NULL,
|
||||||
|
"ticketId" TEXT NOT NULL,
|
||||||
|
|
||||||
|
PRIMARY KEY ("ticketId", "channelId"),
|
||||||
|
CONSTRAINT "archivedChannels_ticketId_fkey" FOREIGN KEY ("ticketId") REFERENCES "tickets" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "archivedMessages" (
|
||||||
|
"authorId" TEXT NOT NULL,
|
||||||
|
"content" TEXT NOT NULL,
|
||||||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"deleted" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"edited" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||||||
|
"external" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"ticketId" TEXT NOT NULL,
|
||||||
|
CONSTRAINT "archivedMessages_ticketId_authorId_fkey" FOREIGN KEY ("ticketId", "authorId") REFERENCES "archivedUsers" ("ticketId", "userId") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT "archivedMessages_ticketId_fkey" FOREIGN KEY ("ticketId") REFERENCES "tickets" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "archivedRoles" (
|
||||||
|
"colour" TEXT NOT NULL DEFAULT '5865F2',
|
||||||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"name" TEXT NOT NULL,
|
||||||
|
"roleId" TEXT NOT NULL,
|
||||||
|
"ticketId" TEXT NOT NULL,
|
||||||
|
|
||||||
|
PRIMARY KEY ("ticketId", "roleId"),
|
||||||
|
CONSTRAINT "archivedRoles_ticketId_fkey" FOREIGN KEY ("ticketId") REFERENCES "tickets" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "archivedUsers" (
|
||||||
|
"avatar" TEXT,
|
||||||
|
"bot" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"discriminator" TEXT,
|
||||||
|
"displayName" TEXT,
|
||||||
|
"roleId" TEXT,
|
||||||
|
"ticketId" TEXT NOT NULL,
|
||||||
|
"userId" TEXT NOT NULL,
|
||||||
|
"username" TEXT,
|
||||||
|
|
||||||
|
PRIMARY KEY ("ticketId", "userId"),
|
||||||
|
CONSTRAINT "archivedUsers_ticketId_roleId_fkey" FOREIGN KEY ("ticketId", "roleId") REFERENCES "archivedRoles" ("ticketId", "roleId") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT "archivedUsers_ticketId_fkey" FOREIGN KEY ("ticketId") REFERENCES "tickets" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "categories" (
|
||||||
|
"channelName" TEXT NOT NULL,
|
||||||
|
"claiming" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"cooldown" INTEGER,
|
||||||
|
"customTopic" TEXT,
|
||||||
|
"description" TEXT NOT NULL,
|
||||||
|
"discordCategory" TEXT NOT NULL,
|
||||||
|
"emoji" TEXT NOT NULL,
|
||||||
|
"enableFeedback" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"guildId" TEXT NOT NULL,
|
||||||
|
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||||
|
"image" TEXT,
|
||||||
|
"memberLimit" INTEGER NOT NULL DEFAULT 1,
|
||||||
|
"name" TEXT NOT NULL,
|
||||||
|
"openingMessage" TEXT NOT NULL,
|
||||||
|
"pingRoles" TEXT NOT NULL DEFAULT '[]',
|
||||||
|
"ratelimit" INTEGER,
|
||||||
|
"requiredRoles" TEXT NOT NULL DEFAULT '[]',
|
||||||
|
"requireTopic" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"staffRoles" TEXT NOT NULL,
|
||||||
|
"totalLimit" INTEGER NOT NULL DEFAULT 50,
|
||||||
|
CONSTRAINT "categories_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "guilds" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "feedback" (
|
||||||
|
"comment" TEXT,
|
||||||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"guildId" TEXT NOT NULL,
|
||||||
|
"rating" INTEGER NOT NULL,
|
||||||
|
"ticketId" TEXT NOT NULL PRIMARY KEY,
|
||||||
|
"userId" TEXT,
|
||||||
|
CONSTRAINT "feedback_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "guilds" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT "feedback_ticketId_fkey" FOREIGN KEY ("ticketId") REFERENCES "tickets" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT "feedback_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users" ("id") ON DELETE SET NULL ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "guilds" (
|
||||||
|
"autoClose" INTEGER NOT NULL DEFAULT 43200000,
|
||||||
|
"autoTag" TEXT NOT NULL DEFAULT '[]',
|
||||||
|
"archive" BOOLEAN NOT NULL DEFAULT true,
|
||||||
|
"blocklist" TEXT NOT NULL DEFAULT '[]',
|
||||||
|
"claimButton" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"closeButton" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"errorColour" TEXT NOT NULL DEFAULT 'Red',
|
||||||
|
"footer" TEXT DEFAULT 'Discord Tickets by eartharoid',
|
||||||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||||||
|
"locale" TEXT NOT NULL DEFAULT 'en-GB',
|
||||||
|
"logChannel" TEXT,
|
||||||
|
"primaryColour" TEXT NOT NULL DEFAULT '#009999',
|
||||||
|
"staleAfter" INTEGER,
|
||||||
|
"successColour" TEXT NOT NULL DEFAULT 'Green',
|
||||||
|
"workingHours" TEXT NOT NULL DEFAULT '["UTC", ["00:00","23:59"], ["00:00","23:59"], ["00:00","23:59"], ["00:00","23:59"], ["00:00","23:59"], ["00:00","23:59"], ["00:00","23:59"]]'
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "questions" (
|
||||||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||||||
|
"categoryId" INTEGER NOT NULL,
|
||||||
|
"label" TEXT NOT NULL,
|
||||||
|
"maxLength" INTEGER DEFAULT 4000,
|
||||||
|
"minLength" INTEGER DEFAULT 0,
|
||||||
|
"options" TEXT NOT NULL DEFAULT '[]',
|
||||||
|
"order" INTEGER NOT NULL,
|
||||||
|
"placeholder" TEXT,
|
||||||
|
"required" BOOLEAN NOT NULL DEFAULT true,
|
||||||
|
"style" INTEGER NOT NULL DEFAULT 2,
|
||||||
|
"type" TEXT NOT NULL DEFAULT 'TEXT',
|
||||||
|
"value" TEXT,
|
||||||
|
CONSTRAINT "questions_categoryId_fkey" FOREIGN KEY ("categoryId") REFERENCES "categories" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "questionAnswers" (
|
||||||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||||
|
"ticketId" TEXT NOT NULL,
|
||||||
|
"questionId" TEXT NOT NULL,
|
||||||
|
"userId" TEXT NOT NULL,
|
||||||
|
"value" TEXT,
|
||||||
|
CONSTRAINT "questionAnswers_ticketId_fkey" FOREIGN KEY ("ticketId") REFERENCES "tickets" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT "questionAnswers_questionId_fkey" FOREIGN KEY ("questionId") REFERENCES "questions" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT "questionAnswers_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "tags" (
|
||||||
|
"content" TEXT NOT NULL,
|
||||||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"guildId" TEXT NOT NULL,
|
||||||
|
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||||
|
"name" TEXT NOT NULL,
|
||||||
|
"regex" TEXT,
|
||||||
|
CONSTRAINT "tags_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "guilds" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "tickets" (
|
||||||
|
"categoryId" INTEGER,
|
||||||
|
"claimedById" TEXT,
|
||||||
|
"closedAt" DATETIME,
|
||||||
|
"closedById" TEXT,
|
||||||
|
"closedReason" TEXT,
|
||||||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"createdById" TEXT NOT NULL,
|
||||||
|
"deleted" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"firstResponseAt" DATETIME,
|
||||||
|
"guildId" TEXT NOT NULL,
|
||||||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||||||
|
"lastMessageAt" DATETIME,
|
||||||
|
"messageCount" INTEGER,
|
||||||
|
"number" INTEGER NOT NULL,
|
||||||
|
"open" BOOLEAN NOT NULL DEFAULT true,
|
||||||
|
"openingMessageId" TEXT NOT NULL,
|
||||||
|
"pinnedMessageIds" TEXT NOT NULL DEFAULT '[]',
|
||||||
|
"priority" TEXT,
|
||||||
|
"referencesMessageId" TEXT,
|
||||||
|
"referencesTicketId" TEXT,
|
||||||
|
"topic" TEXT,
|
||||||
|
CONSTRAINT "tickets_categoryId_fkey" FOREIGN KEY ("categoryId") REFERENCES "categories" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT "tickets_claimedById_fkey" FOREIGN KEY ("claimedById") REFERENCES "users" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT "tickets_closedById_fkey" FOREIGN KEY ("closedById") REFERENCES "users" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT "tickets_createdById_fkey" FOREIGN KEY ("createdById") REFERENCES "users" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT "tickets_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "guilds" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT "tickets_referencesTicketId_fkey" FOREIGN KEY ("referencesTicketId") REFERENCES "tickets" ("id") ON DELETE SET NULL ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "users" (
|
||||||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||||||
|
"messageCount" INTEGER NOT NULL DEFAULT 0
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "archivedChannels_ticketId_channelId_key" ON "archivedChannels"("ticketId", "channelId");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "archivedRoles_ticketId_roleId_key" ON "archivedRoles"("ticketId", "roleId");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "archivedUsers_ticketId_userId_key" ON "archivedUsers"("ticketId", "userId");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "tags_guildId_name_key" ON "tags"("guildId", "name");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "tickets_guildId_number_key" ON "tickets"("guildId", "number");
|
3
db/sqlite/migrations/migration_lock.toml
Normal file
3
db/sqlite/migrations/migration_lock.toml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Please do not edit this file manually
|
||||||
|
# It should be added in your version-control system (i.e. Git)
|
||||||
|
provider = "sqlite"
|
@ -31,6 +31,6 @@ fs.copySync(`./db/${provider}`, './prisma'); // copy schema & migrations
|
|||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
await npx('prisma generate');
|
await npx('prisma generate');
|
||||||
// await npx('prisma migrate deploy');
|
await npx('prisma migrate deploy');
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user