diff --git a/.github/workflows/DB_deploy.yaml b/.github/workflows/DB_deploy.yaml new file mode 100644 index 0000000..9a38c70 --- /dev/null +++ b/.github/workflows/DB_deploy.yaml @@ -0,0 +1,22 @@ +name: Deploy MYSQL DB +on: + push: + branches: + - main + - develop + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v3 + - name: Setup Node + uses: actions/setup-node@v3 + - name: Install dependencies + run: npm install + - run: npm run build + - name: Apply all pending migrations to the database + run: npx prisma migrate deploy + env: + DATABASE_URL: ${{ secrets.DATABASE_URL }} diff --git a/.gitignore b/.gitignore index f9a9def..354b49b 100644 --- a/.gitignore +++ b/.gitignore @@ -126,6 +126,3 @@ dist # Local config file config/local.* - -# Prisma Migrations -prisma/migrations diff --git a/prisma/archived-migrations/20221209172538_initial/migration.sql b/prisma/archived-migrations/20221209172538_initial/migration.sql new file mode 100644 index 0000000..6128a5b --- /dev/null +++ b/prisma/archived-migrations/20221209172538_initial/migration.sql @@ -0,0 +1,114 @@ +-- CreateTable +CREATE TABLE `Users` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `email` VARCHAR(191) NOT NULL, + `password` VARCHAR(191) NULL, + `username` VARCHAR(191) NULL, + `firstname` VARCHAR(191) NULL, + `lastname` VARCHAR(191) NULL, + `bio` VARCHAR(191) NULL, + `timezone` VARCHAR(191) NULL, + `googleProfileId` VARCHAR(191) NULL, + `microsoftProfileId` VARCHAR(191) NULL, + `emailVerified` BOOLEAN NOT NULL DEFAULT false, + `isDeleted` BOOLEAN NOT NULL DEFAULT false, + `onboarding` JSON NOT NULL, + `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), + `updatedAt` DATETIME(3) NOT NULL, + + UNIQUE INDEX `Users_email_key`(`email`), + UNIQUE INDEX `Users_username_key`(`username`), + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `Calendar` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `name` VARCHAR(191) NOT NULL, + `ownerId` INTEGER NOT NULL, + `isDeleted` BOOLEAN NOT NULL DEFAULT false, + + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `EventType` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `name` VARCHAR(191) NOT NULL, + `appGenerated` BOOLEAN NOT NULL, + `ownerId` INTEGER NOT NULL, + `isDeleted` BOOLEAN NOT NULL DEFAULT false, + + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `ParentEvent` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `name` VARCHAR(191) NOT NULL, + `description` VARCHAR(191) NULL, + `ownerId` INTEGER NOT NULL, + `eventTypeId` INTEGER NOT NULL, + `isDeleted` BOOLEAN NOT NULL DEFAULT false, + + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `ChildEvent` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `name` VARCHAR(191) NOT NULL, + `description` VARCHAR(191) NULL, + `location` VARCHAR(191) NULL, + `startTime` DATETIME(3) NOT NULL, + `endTime` DATETIME(3) NOT NULL, + `parentEventID` INTEGER NOT NULL, + `isDeleted` BOOLEAN NOT NULL DEFAULT false, + `usersId` INTEGER NULL, + `eventTypeId` INTEGER NULL, + + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `RecurringEvent` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `eventId` INTEGER NOT NULL, + `recurringFrequency` ENUM('YEARLY', 'MONTHLY', 'WEEKLY', 'DAILY', 'HOURLY') NULL, + `interval` INTEGER NULL, + `count` INTEGER NULL, + `daysOfWeek` VARCHAR(191) NULL, + `weeksOfMonth` VARCHAR(191) NULL, + `daysOfMonth` VARCHAR(191) NULL, + `monthsOfYear` VARCHAR(191) NULL, + + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `Attendees` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `eventId` INTEGER NOT NULL, + `attendeeId` INTEGER NOT NULL, + + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `AccessToken` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `userId` INTEGER NOT NULL, + `associatedEmail` VARCHAR(191) NOT NULL, + `tokenType` ENUM('BEARER') NOT NULL, + `calendarId` VARCHAR(191) NOT NULL, + `calendarType` ENUM('GOOGLECAL', 'OUTLOOKCAL') NOT NULL, + `scope` VARCHAR(191) NOT NULL, + `expiry` INTEGER NOT NULL, + `accessToken` VARCHAR(191) NOT NULL, + `refreshToken` VARCHAR(191) NOT NULL, + `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), + `updatedAt` DATETIME(3) NOT NULL, + + UNIQUE INDEX `AccessToken_userId_calendarId_key`(`userId`, `calendarId`), + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; diff --git a/prisma/archived-migrations/20221210060812_/migration.sql b/prisma/archived-migrations/20221210060812_/migration.sql new file mode 100644 index 0000000..f7b92b0 --- /dev/null +++ b/prisma/archived-migrations/20221210060812_/migration.sql @@ -0,0 +1,3 @@ +-- AlterTable +ALTER TABLE `Calendar` ADD COLUMN `isPrimary` BOOLEAN NOT NULL DEFAULT false, + ADD COLUMN `isSelected` BOOLEAN NOT NULL DEFAULT false; diff --git a/prisma/archived-migrations/20221219191118_/migration.sql b/prisma/archived-migrations/20221219191118_/migration.sql new file mode 100644 index 0000000..9256bce --- /dev/null +++ b/prisma/archived-migrations/20221219191118_/migration.sql @@ -0,0 +1,10 @@ +/* + Warnings: + + - You are about to drop the column `isPrimary` on the `Calendar` table. All the data in the column will be lost. + - You are about to drop the column `isSelected` on the `Calendar` table. All the data in the column will be lost. + +*/ +-- AlterTable +ALTER TABLE `Calendar` DROP COLUMN `isPrimary`, + DROP COLUMN `isSelected`; diff --git a/prisma/archived-migrations/20221219193454_/migration.sql b/prisma/archived-migrations/20221219193454_/migration.sql new file mode 100644 index 0000000..4e3ca8f --- /dev/null +++ b/prisma/archived-migrations/20221219193454_/migration.sql @@ -0,0 +1,11 @@ +/* + Warnings: + + - You are about to drop the column `usersId` on the `ChildEvent` table. All the data in the column will be lost. + +*/ +-- AlterTable +ALTER TABLE `Calendar` ADD COLUMN `isPrimary` BOOLEAN NOT NULL DEFAULT false; + +-- AlterTable +ALTER TABLE `ChildEvent` DROP COLUMN `usersId`; diff --git a/prisma/archived-migrations/20221222130847_/migration.sql b/prisma/archived-migrations/20221222130847_/migration.sql new file mode 100644 index 0000000..6e86369 --- /dev/null +++ b/prisma/archived-migrations/20221222130847_/migration.sql @@ -0,0 +1,8 @@ +/* + Warnings: + + - Added the required column `calendarId` to the `ParentEvent` table without a default value. This is not possible if the table is not empty. + +*/ +-- AlterTable +ALTER TABLE `ParentEvent` ADD COLUMN `calendarId` INTEGER NOT NULL; diff --git a/prisma/archived-migrations/20221227183814_/migration.sql b/prisma/archived-migrations/20221227183814_/migration.sql new file mode 100644 index 0000000..f30babe --- /dev/null +++ b/prisma/archived-migrations/20221227183814_/migration.sql @@ -0,0 +1,16 @@ +/* + Warnings: + + - You are about to drop the column `eventTypeId` on the `ChildEvent` table. All the data in the column will be lost. + - Changed the type of `expiry` on the `AccessToken` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required. + - Added the required column `calendarId` to the `ChildEvent` table without a default value. This is not possible if the table is not empty. + +*/ +-- AlterTable +ALTER TABLE `AccessToken` ADD COLUMN `isDeleted` BOOLEAN NOT NULL DEFAULT false, + DROP COLUMN `expiry`, + ADD COLUMN `expiry` DATETIME(3) NOT NULL; + +-- AlterTable +ALTER TABLE `ChildEvent` DROP COLUMN `eventTypeId`, + ADD COLUMN `calendarId` INTEGER NOT NULL; diff --git a/prisma/archived-migrations/20230201181349_init/migration.sql b/prisma/archived-migrations/20230201181349_init/migration.sql new file mode 100644 index 0000000..8f3efdb --- /dev/null +++ b/prisma/archived-migrations/20230201181349_init/migration.sql @@ -0,0 +1,12 @@ +/* + Warnings: + + - You are about to drop the column `calendarId` on the `ChildEvent` table. All the data in the column will be lost. + - You are about to drop the column `calendarId` on the `ParentEvent` table. All the data in the column will be lost. + +*/ +-- AlterTable +ALTER TABLE `ChildEvent` DROP COLUMN `calendarId`; + +-- AlterTable +ALTER TABLE `ParentEvent` DROP COLUMN `calendarId`; diff --git a/prisma/archived-migrations/20230302145202_v1/migration.sql b/prisma/archived-migrations/20230302145202_v1/migration.sql new file mode 100644 index 0000000..073fa20 --- /dev/null +++ b/prisma/archived-migrations/20230302145202_v1/migration.sql @@ -0,0 +1,24 @@ +/* + Warnings: + + - You are about to drop the `ChildEvent` table. If the table is not empty, all the data it contains will be lost. + - You are about to drop the `ParentEvent` table. If the table is not empty, all the data it contains will be lost. + +*/ +-- DropTable +DROP TABLE `ChildEvent`; + +-- DropTable +DROP TABLE `ParentEvent`; + +-- CreateTable +CREATE TABLE `Event` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `name` VARCHAR(191) NOT NULL, + `description` VARCHAR(191) NULL, + `ownerId` INTEGER NOT NULL, + `eventTypeId` INTEGER NOT NULL, + `isDeleted` BOOLEAN NOT NULL DEFAULT false, + + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; diff --git a/prisma/archived-migrations/20230302152353_v2/migration.sql b/prisma/archived-migrations/20230302152353_v2/migration.sql new file mode 100644 index 0000000..f438864 --- /dev/null +++ b/prisma/archived-migrations/20230302152353_v2/migration.sql @@ -0,0 +1,11 @@ +/* + Warnings: + + - Added the required column `endTime` to the `Event` table without a default value. This is not possible if the table is not empty. + - Added the required column `startTime` to the `Event` table without a default value. This is not possible if the table is not empty. + +*/ +-- AlterTable +ALTER TABLE `Event` ADD COLUMN `endTime` DATETIME(3) NOT NULL, + ADD COLUMN `location` VARCHAR(191) NULL, + ADD COLUMN `startTime` DATETIME(3) NOT NULL; diff --git a/prisma/archived-migrations/20230302152631_v2/migration.sql b/prisma/archived-migrations/20230302152631_v2/migration.sql new file mode 100644 index 0000000..7a93cf4 --- /dev/null +++ b/prisma/archived-migrations/20230302152631_v2/migration.sql @@ -0,0 +1,8 @@ +/* + Warnings: + + - Added the required column `calendarId` to the `Event` table without a default value. This is not possible if the table is not empty. + +*/ +-- AlterTable +ALTER TABLE `Event` ADD COLUMN `calendarId` INTEGER NOT NULL; diff --git a/prisma/archived-migrations/20231110171102_is_private_additino/migration.sql b/prisma/archived-migrations/20231110171102_is_private_additino/migration.sql new file mode 100644 index 0000000..d64cea3 --- /dev/null +++ b/prisma/archived-migrations/20231110171102_is_private_additino/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE `Event` ADD COLUMN `isPrivate` BOOLEAN NOT NULL DEFAULT true; diff --git a/prisma/migrations/migration_lock.toml b/prisma/archived-migrations/migration_lock.toml similarity index 100% rename from prisma/migrations/migration_lock.toml rename to prisma/archived-migrations/migration_lock.toml diff --git a/prisma/migrations/0_init/migration.sql b/prisma/migrations/0_init/migration.sql new file mode 100644 index 0000000..0461308 --- /dev/null +++ b/prisma/migrations/0_init/migration.sql @@ -0,0 +1,106 @@ +-- CreateTable +CREATE TABLE `Users` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `email` VARCHAR(191) NOT NULL, + `password` VARCHAR(191) NULL, + `username` VARCHAR(191) NULL, + `firstname` VARCHAR(191) NULL, + `lastname` VARCHAR(191) NULL, + `bio` VARCHAR(191) NULL, + `timezone` VARCHAR(191) NULL, + `googleProfileId` VARCHAR(191) NULL, + `microsoftProfileId` VARCHAR(191) NULL, + `emailVerified` BOOLEAN NOT NULL DEFAULT false, + `isDeleted` BOOLEAN NOT NULL DEFAULT false, + `onboarding` JSON NOT NULL, + `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), + `updatedAt` DATETIME(3) NOT NULL, + + UNIQUE INDEX `Users_email_key`(`email`), + UNIQUE INDEX `Users_username_key`(`username`), + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `Calendar` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `name` VARCHAR(191) NOT NULL, + `ownerId` INTEGER NOT NULL, + `isPrimary` BOOLEAN NOT NULL DEFAULT false, + `isDeleted` BOOLEAN NOT NULL DEFAULT false, + + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `EventType` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `name` VARCHAR(191) NOT NULL, + `appGenerated` BOOLEAN NOT NULL, + `ownerId` INTEGER NOT NULL, + `isDeleted` BOOLEAN NOT NULL DEFAULT false, + + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `Event` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `name` VARCHAR(191) NOT NULL, + `description` VARCHAR(191) NULL, + `location` VARCHAR(191) NULL, + `startTime` DATETIME(3) NOT NULL, + `endTime` DATETIME(3) NOT NULL, + `ownerId` INTEGER NOT NULL, + `eventTypeId` INTEGER NOT NULL, + `calendarId` INTEGER NOT NULL, + `isPrivate` BOOLEAN NOT NULL DEFAULT true, + `isDeleted` BOOLEAN NOT NULL DEFAULT false, + + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `RecurringEvent` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `eventId` INTEGER NOT NULL, + `recurringFrequency` ENUM('YEARLY', 'MONTHLY', 'WEEKLY', 'DAILY', 'HOURLY') NULL, + `interval` INTEGER NULL, + `count` INTEGER NULL, + `daysOfWeek` VARCHAR(191) NULL, + `weeksOfMonth` VARCHAR(191) NULL, + `daysOfMonth` VARCHAR(191) NULL, + `monthsOfYear` VARCHAR(191) NULL, + + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `Attendees` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `eventId` INTEGER NOT NULL, + `attendeeId` INTEGER NOT NULL, + + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `AccessToken` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `userId` INTEGER NOT NULL, + `associatedEmail` VARCHAR(191) NOT NULL, + `tokenType` ENUM('BEARER') NOT NULL, + `calendarId` VARCHAR(191) NOT NULL, + `calendarType` ENUM('GOOGLECAL', 'OUTLOOKCAL') NOT NULL, + `scope` VARCHAR(191) NOT NULL, + `expiry` DATETIME(3) NOT NULL, + `accessToken` VARCHAR(191) NOT NULL, + `refreshToken` VARCHAR(191) NOT NULL, + `isDeleted` BOOLEAN NOT NULL DEFAULT false, + `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), + `updatedAt` DATETIME(3) NOT NULL, + + UNIQUE INDEX `AccessToken_userId_calendarId_key`(`userId`, `calendarId`), + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +