diff --git a/.github/workflows/prisma-pending-migrations.yml b/.github/workflows/prisma-pending-migrations.yml index 034fc432c..a7a2efa1c 100644 --- a/.github/workflows/prisma-pending-migrations.yml +++ b/.github/workflows/prisma-pending-migrations.yml @@ -6,6 +6,8 @@ jobs: pending-migrations: name: Pending Migrations runs-on: ubuntu-latest + env: + DB: postgresql://gw2treasures:gw2treasures@localhost:5432/gw2treasures services: database: image: timescale/timescaledb:2.17.2-pg17 @@ -24,6 +26,10 @@ jobs: - uses: actions/checkout@v4 - name: Setup Node.js env uses: ./.github/actions/setup-node-env + - name: Setup database + run: | + psql "${{ env.DB }}" -c 'CREATE EXTENSION IF NOT EXISTS "timescaledb";' + psql "${{ env.DB }}" -c 'ALTER EXTENSION "timescaledb" UPDATE;' - name: Run prisma diff run: | pnpm --filter @gw2treasures/database exec \ @@ -31,4 +37,4 @@ jobs: --exit-code \ --from-schema-datamodel "./prisma/schema.prisma" \ --to-migrations "./prisma/migrations" \ - --shadow-database-url "postgresql://gw2treasures:gw2treasures@localhost:5432/gw2treasures?schema=public" + --shadow-database-url "${{ env.DB }}?schema=public" diff --git a/packages/database/prisma/migrations/20240103232706_enable_timescale/migration.sql b/packages/database/prisma/migrations/20240103232706_enable_timescale/migration.sql index fb3b6c66c..2f2068de6 100644 --- a/packages/database/prisma/migrations/20240103232706_enable_timescale/migration.sql +++ b/packages/database/prisma/migrations/20240103232706_enable_timescale/migration.sql @@ -1,5 +1,8 @@ -- enable extension -CREATE EXTENSION IF NOT EXISTS "timescaledb"; +-- CREATE EXTENSION IF NOT EXISTS "timescaledb"; +SELECT * FROM pg_extension; + +SELECT CURRENT_SCHEMA; -- create hypertable TradingPostHistory SELECT create_hypertable('"TradingPostHistory"', by_range('time'), migrate_data => true, create_default_indexes => false);