Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to PostgreSQL #2056

Merged
merged 1 commit into from
Feb 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 5 additions & 26 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,17 @@ on:

jobs:
test:
# strategy:
# fail-fast: false
# matrix:
# os: [ubuntu-22.04, macos-14]
# runs-on: ${{ matrix.os }}
runs-on: macos-14
steps:
# https://github.com/actions/runner-images/issues/9330
- name: Allow microphone access to all apps (macOS)
# if: matrix.os == 'macos-14'
- name: Allow microphone access to all apps
run: |
sqlite3 $HOME/Library/Application\ Support/com.apple.TCC/TCC.db "INSERT OR IGNORE INTO access VALUES ('kTCCServiceMicrophone','/usr/local/opt/runner/provisioner/provisioner',1,2,4,1,NULL,NULL,0,'UNUSED',NULL,0,1687786159,NULL,NULL,'UNUSED',1687786159);"

# - name: Set up PulseAudio (Ubuntu)
# if: matrix.os == 'ubuntu-22.04'
# run: |
# sudo apt-get update
# sudo apt-get install -y pulseaudio
# systemctl --user start pulseaudio.socket

- name: Install MySQL (macOS)
# if: matrix.os == 'macos-14'
- name: Install PostgreSQL
run: |
brew install mysql
brew services start mysql

# - name: Start MySQL (Ubuntu)
# if: matrix.os == 'ubuntu-22.04'
# run: sudo systemctl start mysql
brew install postgresql@16
brew services start postgresql@16

- name: Check out repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
Expand All @@ -57,10 +39,7 @@ jobs:
env:
CLERK_PUBLISHABLE_KEY: ${{ secrets.CLERK_PUBLISHABLE_KEY }}
CLERK_SECRET_KEY: ${{ secrets.CLERK_SECRET_KEY }}
# On macOS (installed via Homebrew), the MySQL root password is empty by default
# On Ubuntu (included in runner image), the MySQL root password is "root" by default
# DATABASE_URL: mysql://root:${{ matrix.os == 'ubuntu-22.04' && 'root' || '' }}@localhost:3306/festival
DATABASE_URL: mysql://root:@localhost:3306/festival
DATABASE_URL: postgresql://runner:@localhost:5432/postgres
FIRST_ADMIN_EMAIL_ADDRESS: [email protected]
PORT: '3000'
TIGRIS_ACCESS_KEY_ID: ${{ secrets.TIGRIS_ACCESS_KEY_ID }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ at the same time) without requiring live streaming infrastructure.
## Local Development

- Copy `.env.sample` to `.env` and fill out the required values.
- Run `docker compose up -d` to start a MySQL database.
- Run `docker compose up -d` to start a PostgreSQL database.
- Run `npm install` to install the required packages.
- Run `npm run dev` to serve the application locally.

Expand Down
6 changes: 0 additions & 6 deletions db-init/create-users.sql

This file was deleted.

7 changes: 3 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
name: festival-dev
services:
db:
image: mysql:lts@sha256:0917ecc5863323a48203dda0bb7d58582d958da62914024c474bf2e8c5f5ee73
image: postgres:16
env_file: .env
volumes:
- db-data:/var/lib/mysql
- ./db-init:/docker-entrypoint-initdb.d
- db-data:/var/lib/postgresql/data
ports:
- 3306:3306
- 5432:5432
volumes:
db-data:
85 changes: 0 additions & 85 deletions prisma/migrations/20230703193148_init/migration.sql

This file was deleted.

This file was deleted.

13 changes: 0 additions & 13 deletions prisma/migrations/20240702043959_rename_file/migration.sql

This file was deleted.

This file was deleted.

This file was deleted.

34 changes: 0 additions & 34 deletions prisma/migrations/20240705180756_show_optional_data/migration.sql

This file was deleted.

This file was deleted.

6 changes: 0 additions & 6 deletions prisma/migrations/20250124043644_tigris/migration.sql

This file was deleted.

This file was deleted.

83 changes: 83 additions & 0 deletions prisma/migrations/20250223044619_init/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
-- CreateEnum
CREATE TYPE "AudioFileConversionStatus" AS ENUM ('USER_UPLOAD', 'CHECKING', 'CONVERTING', 'RE_UPLOAD', 'DONE', 'ERROR');

-- CreateTable
CREATE TABLE "Show" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"slug" TEXT NOT NULL,
"description" TEXT,
"startDate" TEXT,
"timeZone" TEXT NOT NULL,
"backgroundColor" TEXT,
"backgroundColorSecondary" TEXT,
"logoImageFileId" TEXT,
"backgroundImageFileId" TEXT,

CONSTRAINT "Show_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Set" (
"id" TEXT NOT NULL,
"artist" TEXT,
"offset" DOUBLE PRECISION,
"showId" TEXT NOT NULL,
"audioFileId" TEXT,

CONSTRAINT "Set_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "AudioFile" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"url" TEXT NOT NULL,
"duration" DOUBLE PRECISION,
"conversionStatus" "AudioFileConversionStatus" NOT NULL,
"conversionProgress" DOUBLE PRECISION,
"errorMessage" TEXT,

CONSTRAINT "AudioFile_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "ImageFile" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"url" TEXT NOT NULL,

CONSTRAINT "ImageFile_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "AdminUserAllowlist" (
"emailAddress" TEXT NOT NULL
);

-- CreateIndex
CREATE UNIQUE INDEX "Show_slug_key" ON "Show"("slug");

-- CreateIndex
CREATE UNIQUE INDEX "Show_logoImageFileId_key" ON "Show"("logoImageFileId");

-- CreateIndex
CREATE UNIQUE INDEX "Show_backgroundImageFileId_key" ON "Show"("backgroundImageFileId");

-- CreateIndex
CREATE UNIQUE INDEX "Set_audioFileId_key" ON "Set"("audioFileId");

-- CreateIndex
CREATE UNIQUE INDEX "AdminUserAllowlist_emailAddress_key" ON "AdminUserAllowlist"("emailAddress");

-- AddForeignKey
ALTER TABLE "Show" ADD CONSTRAINT "Show_logoImageFileId_fkey" FOREIGN KEY ("logoImageFileId") REFERENCES "ImageFile"("id") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Show" ADD CONSTRAINT "Show_backgroundImageFileId_fkey" FOREIGN KEY ("backgroundImageFileId") REFERENCES "ImageFile"("id") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Set" ADD CONSTRAINT "Set_showId_fkey" FOREIGN KEY ("showId") REFERENCES "Show"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Set" ADD CONSTRAINT "Set_audioFileId_fkey" FOREIGN KEY ("audioFileId") REFERENCES "AudioFile"("id") ON DELETE SET NULL ON UPDATE CASCADE;
4 changes: 2 additions & 2 deletions prisma/migrations/migration_lock.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
provider = "mysql"
# It should be added in your version-control system (e.g., Git)
provider = "postgresql"
2 changes: 1 addition & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ generator client {
}

datasource db {
provider = "mysql"
provider = "postgresql"
url = env("DATABASE_URL")
}

Expand Down
Loading