Skip to content

Commit

Permalink
github action setup for db deployment (#116)
Browse files Browse the repository at this point in the history
* github action setup

* Migration configuration

* Remove migrations from git-ignore

* migration commit
  • Loading branch information
prakashchoudhary07 authored Nov 11, 2023
1 parent bc05a9f commit 9a12153
Show file tree
Hide file tree
Showing 15 changed files with 347 additions and 3 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/DB_deploy.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,3 @@ dist

# Local config file
config/local.*

# Prisma Migrations
prisma/migrations
114 changes: 114 additions & 0 deletions prisma/archived-migrations/20221209172538_initial/migration.sql
Original file line number Diff line number Diff line change
@@ -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;
3 changes: 3 additions & 0 deletions prisma/archived-migrations/20221210060812_/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- AlterTable
ALTER TABLE `Calendar` ADD COLUMN `isPrimary` BOOLEAN NOT NULL DEFAULT false,
ADD COLUMN `isSelected` BOOLEAN NOT NULL DEFAULT false;
10 changes: 10 additions & 0 deletions prisma/archived-migrations/20221219191118_/migration.sql
Original file line number Diff line number Diff line change
@@ -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`;
11 changes: 11 additions & 0 deletions prisma/archived-migrations/20221219193454_/migration.sql
Original file line number Diff line number Diff line change
@@ -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`;
8 changes: 8 additions & 0 deletions prisma/archived-migrations/20221222130847_/migration.sql
Original file line number Diff line number Diff line change
@@ -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;
16 changes: 16 additions & 0 deletions prisma/archived-migrations/20221227183814_/migration.sql
Original file line number Diff line number Diff line change
@@ -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;
12 changes: 12 additions & 0 deletions prisma/archived-migrations/20230201181349_init/migration.sql
Original file line number Diff line number Diff line change
@@ -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`;
24 changes: 24 additions & 0 deletions prisma/archived-migrations/20230302145202_v1/migration.sql
Original file line number Diff line number Diff line change
@@ -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;
11 changes: 11 additions & 0 deletions prisma/archived-migrations/20230302152353_v2/migration.sql
Original file line number Diff line number Diff line change
@@ -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;
8 changes: 8 additions & 0 deletions prisma/archived-migrations/20230302152631_v2/migration.sql
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE `Event` ADD COLUMN `isPrivate` BOOLEAN NOT NULL DEFAULT true;
File renamed without changes.
106 changes: 106 additions & 0 deletions prisma/migrations/0_init/migration.sql
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 9a12153

Please sign in to comment.