Skip to content
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
9 changes: 6 additions & 3 deletions .github/workflows/database_cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ on:
pull_request:
types:
- closed
paths-ignore:
- .gitignore
- .github/**
- README.md
workflow_dispatch:
inputs:
pr_number:
Expand All @@ -13,6 +17,8 @@ on:
jobs:
cleanup_database:
runs-on: ubuntu-latest
env:
TURSO_API_TOKEN: ${{ secrets.TURSO_API_TOKEN }}
steps:
- name: Install Turso CLI
run: |
Expand All @@ -30,8 +36,5 @@ jobs:
echo "DB_NAME=$DB_NAME" >> $GITHUB_ENV

- name: Destroy Turso Database
env:
TURSO_API_TOKEN: ${{ secrets.TURSO_API_TOKEN }}
DB_NAME: ${{ env.DB_NAME }}
run: |
turso db destroy "$DB_NAME" --yes || echo "Database already gone or never existed"
6 changes: 3 additions & 3 deletions .github/workflows/dev_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ permissions:

concurrency:
group: deployment-dev
cancel-in-progress: true
cancel-in-progress: false

jobs:
deploy:
Expand All @@ -36,12 +36,12 @@ jobs:
TURSO_DATABASE_URL: ${{ secrets.DEV_DB_URL }}
TURSO_AUTH_TOKEN: ${{ secrets.DEV_DB_TOKEN }}
run: |
npx drizzle-kit push
npx drizzle-kit migrate

- name: Make Development Deployment
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
run: |
npx vercel deploy --target preview --yes --token ${{ secrets.VERCEL_TOKEN }}
npx vercel deploy --target preview --yes --token "$VERCEL_TOKEN"
18 changes: 9 additions & 9 deletions .github/workflows/pr_preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
type: number

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.inputs.pr_number }}
cancel-in-progress: true

permissions:
Expand Down Expand Up @@ -59,7 +59,7 @@ jobs:
TURSO_API_TOKEN: ${{ secrets.TURSO_API_TOKEN }}
run: |
# Create a branch from the dev database with the generated safe name
turso db create ${{ env.SAFE_BRANCH_NAME }} --from-db dev || true
turso db show ${{ env.SAFE_BRANCH_NAME }} &> /dev/null || turso db create ${{ env.SAFE_BRANCH_NAME }} --from-db dev

- name: Get Database Credentials
env:
Expand All @@ -82,7 +82,7 @@ jobs:
TURSO_AUTH_TOKEN: ${{ env.DB_TOKEN }}
run: |
# Push changes to the created database
npx drizzle-kit push
npx drizzle-kit migrate

- name: Make Preview Deployment
id: vercel-deployment
Expand All @@ -92,17 +92,17 @@ jobs:
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
run: |
# Make a preview deployment with the created database
DEPLOYMENT_URL=$(npx vercel deploy --target preview --token ${{ secrets.VERCEL_TOKEN }} \
--build-env TURSO_DATABASE_URL=${{ env.DB_URL }} \
--build-env TURSO_AUTH_TOKEN=${{ env.DB_TOKEN }} \
--env TURSO_DATABASE_URL=${{ env.DB_URL }} \
--env TURSO_AUTH_TOKEN=${{ env.DB_TOKEN }} \
DEPLOYMENT_URL=$(npx vercel deploy --target preview --token "$VERCEL_TOKEN" \
--build-env TURSO_DATABASE_URL="$DB_URL" \
--build-env TURSO_AUTH_TOKEN="$DB_TOKEN" \
--env TURSO_DATABASE_URL="$DB_URL" \
--env TURSO_AUTH_TOKEN="$DB_TOKEN" \
--yes --logs)

echo "DEPLOYMENT_URL=$DEPLOYMENT_URL" >> $GITHUB_ENV

- name: Comment on PR
if: always()
if: always() && env.PR_NUM != ''
uses: actions/github-script@v8
env:
DEPLOYMENT_URL: ${{ env.DEPLOYMENT_URL }}
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/production_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ on:
- README.md
workflow_dispatch:

concurrency:
group: deployment-production
cancel-in-progress: false

jobs:
deploy:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -37,4 +41,4 @@ jobs:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
run: |
npx vercel deploy --prod --yes --token ${{ secrets.VERCEL_TOKEN }}
npx vercel deploy --prod --yes --token "$VERCEL_TOKEN"
24 changes: 24 additions & 0 deletions drizzle/0001_lucky_lucky_pierre.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
ALTER TABLE `database` RENAME COLUMN "user_id" TO "team_id";--> statement-breakpoint
CREATE TABLE `team` (
`id` text PRIMARY KEY NOT NULL,
`slug` text NOT NULL,
`display_name` text NOT NULL,
`name` text NOT NULL,
`owner_id` text NOT NULL,
`created_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL,
FOREIGN KEY (`owner_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE restrict
);
--> statement-breakpoint
CREATE UNIQUE INDEX `team_slug_unique` ON `team` (`slug`);--> statement-breakpoint
CREATE TABLE `team_member` (
`user_id` text NOT NULL,
`team_id` text NOT NULL,
`role` text NOT NULL,
`created_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL,
PRIMARY KEY(`user_id`, `team_id`),
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade,
FOREIGN KEY (`team_id`) REFERENCES `team`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
ALTER TABLE `database` ADD `created_by` text REFERENCES user(id);--> statement-breakpoint
ALTER TABLE `database` ALTER COLUMN "team_id" TO "team_id" text NOT NULL REFERENCES team(id) ON DELETE cascade ON UPDATE no action;
Loading
Loading