Skip to content

Instantly share code, notes, and snippets.

@bwlng

bwlng/migrate.sh Secret

Created February 25, 2024 22:28
Show Gist options
  • Save bwlng/6d7a87916236bc14cef0bda93267d621 to your computer and use it in GitHub Desktop.
Save bwlng/6d7a87916236bc14cef0bda93267d621 to your computer and use it in GitHub Desktop.
Kysely migrations
#!/usr/bin/env bash
# Ensure script stops when commands fail.
set -e
echo "Migrating database..."
# Ensure the dist directory exists.
mkdir -p ./db/dist
mkdir -p ./db/dist/migrations
# Compile the TypeScript files to JavaScript.
npx tsc --outDir ./db/dist ./db/*.ts --target ESNext --moduleResolution node --module ESNext --esModuleInterop true
npx tsc --outDir ./db/dist/migrations ./db/migrations/*.ts --target ESNext --moduleResolution node --module ESNext --esModuleInterop true
# Run the migrations.
node ./db/dist/migrate.js
# Remove the dist directory.
rm -r ./db/dist
echo "Migrations complete."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment