🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix: clean up broken migration history (#2329)
Max Deichmann46b19279c4dc
diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.ymlindex b1da98e394..85a335950a 100644--- a/.github/workflows/pipeline.yml+++ b/.github/workflows/pipeline.yml@@ -67,6 +67,7 @@ jobs:strategy:matrix:node-version: [20]+ postgres-version: [12, 15]steps:- name: Set Swap Spaceuses: pierotofy/set-swap-space@master@@ -97,6 +98,9 @@ jobs:run: |docker compose -f docker-compose.dev.yml up -dsleep 5 # Wait for PostgreSQL to accept connections+ docker compose ps+ env:+ POSTGRES_VERSION: ${{ matrix.postgres-version }}- name: Seed DBrun: |@@ -117,6 +121,7 @@ jobs:strategy:matrix:node-version: [20]+ postgres-version: [12, 15]steps:- name: Set Swap Spaceuses: pierotofy/set-swap-space@master@@ -147,6 +152,7 @@ jobs:run: |docker compose -f docker-compose.dev.yml up -dsleep 5 # Wait for PostgreSQL to accept connections+ docker compose ps- name: Seed DBrun: |@@ -184,6 +190,7 @@ jobs:- name: Run + migraterun: |docker compose -f docker-compose.dev.yml up -d+ docker compose pssleep 5 # Wait for PostgreSQL to accept connections- name: Seed DBdiff --git a/docker-compose.dev.yml b/docker-compose.dev.ymlindex 9ef53de53f..c2e2942049 100644--- a/docker-compose.dev.yml+++ b/docker-compose.dev.yml@@ -1,5 +1,3 @@-version: "3.5"-services:redis:image: redis:7.2.4@@ -10,7 +8,7 @@ services:- 6379:6379db:- image: postgres+ image: postgres:${POSTGRES_VERSION:-latest}restart: alwayscommand: ["postgres", "-c", "log_statement=all"]environment:diff --git a/packages/shared/prisma/migrations/20240530212419_model_price_anthropic_via_google_vertex/migration.sql b/packages/shared/prisma/migrations/20240530212419_model_price_anthropic_via_google_vertex/migration.sqldeleted file mode 100644index f4e36d0d8d..0000000000--- a/packages/shared/prisma/migrations/20240530212419_model_price_anthropic_via_google_vertex/migration.sql+++ /dev/null@@ -1,7 +0,0 @@--- Google Vertex uses @ to separate model name and version--UPDATE "public"."models" SET "match_pattern" = '(?i)^(claude-3-haiku(-|@)?20240307)$' WHERE "id" = 'cltr0w45b000008k1407o9qv1';--UPDATE "public"."models" SET "match_pattern" = '(?i)^(claude-3-opus(-|@)?20240229)$' WHERE "id" = 'cltgy0iuw000008le3vod1hhy';--UPDATE "public"."models" SET "match_pattern" = '(?i)^(claude-3-sonnet(-|@)?20240229)$' WHERE "id" = 'cltgy0pp6000108le56se7bl3';\ No newline at end of filediff --git a/packages/shared/prisma/migrations/20240606090858_pricings_add_latest_gemini_models/migration.sql b/packages/shared/prisma/migrations/20240606090858_pricings_add_latest_gemini_models/migration.sqldeleted file mode 100644index eaebbbe05e..0000000000--- a/packages/shared/prisma/migrations/20240606090858_pricings_add_latest_gemini_models/migration.sql+++ /dev/null@@ -1,5 +0,0 @@--- does not include pricing yet, will be added as soon as it is calculated at ingestion time--INSERT INTO "public"."models" ("id", "model_name", "match_pattern", "unit") VALUES ('clx30djsn0000w9mzebiv41we', 'gemini-1.5-flash', '(?i)^(gemini-1.5-flash)(@[a-zA-Z0-9]+)?$', 'CHARACTERS');--INSERT INTO "public"."models" ("id", "model_name", "match_pattern", "unit") VALUES ('clx30hkrx0000w9mz7lqi0ial', 'gemini-1.5-pro', '(?i)^(gemini-1.5-pro)(@[a-zA-Z0-9]+)?$', 'CHARACTERS');\ No newline at end of filediff --git a/packages/shared/prisma/migrations/20240607090858_pricings_add_latest_gemini_models/migration.sql b/packages/shared/prisma/migrations/20240607090858_pricings_add_latest_gemini_models/migration.sqlnew file mode 100644index 0000000000..261b909b02--- /dev/null+++ b/packages/shared/prisma/migrations/20240607090858_pricings_add_latest_gemini_models/migration.sql@@ -0,0 +1,8 @@+-- does not include pricing yet, will be added as soon as it is calculated at ingestion time++-- remove model if added by faulty migration, context: https://github.com/langfuse/langfuse/issues/2266+DELETE FROM models WHERE id in ('clx30djsn0000w9mzebiv41we', 'clx30hkrx0000w9mz7lqi0ial');++INSERT INTO "models" ("id", "model_name", "match_pattern", "unit") VALUES ('clx30djsn0000w9mzebiv41we', 'gemini-1.5-flash', '(?i)^(gemini-1.5-flash)(@[a-zA-Z0-9]+)?$', 'CHARACTERS');++INSERT INTO "models" ("id", "model_name", "match_pattern", "unit") VALUES ('clx30hkrx0000w9mz7lqi0ial', 'gemini-1.5-pro', '(?i)^(gemini-1.5-pro)(@[a-zA-Z0-9]+)?$', 'CHARACTERS');\ No newline at end of filediff --git a/packages/shared/prisma/migrations/20240607212419_model_price_anthropic_via_google_vertex/migration.sql b/packages/shared/prisma/migrations/20240607212419_model_price_anthropic_via_google_vertex/migration.sqlnew file mode 100644index 0000000000..addb980658--- /dev/null+++ b/packages/shared/prisma/migrations/20240607212419_model_price_anthropic_via_google_vertex/migration.sql@@ -0,0 +1,7 @@+-- Google Vertex uses @ to separate model name and version++UPDATE "models" SET "match_pattern" = '(?i)^(claude-3-haiku(-|@)?20240307)$' WHERE "id" = 'cltr0w45b000008k1407o9qv1';++UPDATE "models" SET "match_pattern" = '(?i)^(claude-3-opus(-|@)?20240229)$' WHERE "id" = 'cltgy0iuw000008le3vod1hhy';++UPDATE "models" SET "match_pattern" = '(?i)^(claude-3-sonnet(-|@)?20240229)$' WHERE "id" = 'cltgy0pp6000108le56se7bl3';\ No newline at end of filediff --git a/packages/shared/prisma/migrations/20240604133340_backfill_manual_scores/migration.sql b/packages/shared/prisma/migrations/20240611113517_backfill_manual_score_configs/migration.sqlsimilarity index 87%rename from packages/shared/prisma/migrations/20240604133340_backfill_manual_scores/migration.sqlrename to packages/shared/prisma/migrations/20240611113517_backfill_manual_score_configs/migration.sqlindex 748b160947..d69cefee06 100644--- a/packages/shared/prisma/migrations/20240604133340_backfill_manual_scores/migration.sql+++ b/packages/shared/prisma/migrations/20240611113517_backfill_manual_score_configs/migration.sql@@ -10,7 +10,7 @@ INSERT INTO score_configs (id,max_value,description)SELECT- gen_random_uuid () AS id,+ md5(random()::text || clock_timestamp()::text || s.project_id::text)::uuid AS id,s.project_id,'manual-score','NUMERIC',@@ -24,6 +24,7 @@ FROM ( SELECT DISTINCTscoresWHEREname = 'manual-score'+ AND config_id IS NULLAND source = 'ANNOTATION') sWHERENOT EXISTS (@@ -47,4 +48,4 @@ FROMWHEREscores.project_id = pc.project_idAND scores.name = 'manual-score';-COMMIT;+COMMIT;\ No newline at end of filediff --git a/packages/shared/scripts/cleanup.sql b/packages/shared/scripts/cleanup.sqlnew file mode 100644index 0000000000..d1293fadf0--- /dev/null+++ b/packages/shared/scripts/cleanup.sql@@ -0,0 +1,7 @@+DO $$+BEGIN+ IF EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = '_prisma_migrations') THEN+ DELETE FROM _prisma_migrations+ WHERE migration_name IN ('20240606090858_pricings_add_latest_gemini_models', '20240530212419_model_price_anthropic_via_google_vertex', '20240604133340_backfill_manual_scores');+ END IF;+END $$;\ No newline at end of filediff --git a/turbo.json b/turbo.jsonindex 45c45d3b33..c102d9b5e7 100644--- a/turbo.json+++ b/turbo.json@@ -9,7 +9,9 @@"start": {"dependsOn": ["^start"]},- "db:migrate": {},+ "db:migrate": {+ "cache": false+ },"db:deploy": {},"db:reset": {},"db:push": {},diff --git a/web/Dockerfile b/web/Dockerfileindex 578976dc19..a246399b0a 100644--- a/web/Dockerfile+++ b/web/Dockerfile@@ -78,6 +78,7 @@ COPY --from=builder --chown=nextjs:nodejs /app/web/public ./web/publicCOPY --from=builder --chown=nextjs:nodejs /app/packages/shared/prisma ./packages/shared/prismaCOPY --chown=nextjs:nodejs ./web/entrypoint.sh ./web/entrypoint.sh+COPY --chown=nextjs:nodejs ./packages/shared/scripts/cleanup.sql ./packages/shared/scripts/cleanup.sqlRUN chmod +x ./web/entrypoint.shUSER nextjsdiff --git a/web/entrypoint.sh b/web/entrypoint.shindex 51d49af930..ae58f4c305 100644--- a/web/entrypoint.sh+++ b/web/entrypoint.sh@@ -1,5 +1,6 @@#!/bin/sh+# Run cleanup script before running migrations# Check if DATABASE_URL is not setif [ -z "$DATABASE_URL" ]; then# Check if all required variables are provided@@ -18,6 +19,8 @@ if [ -z "$DIRECT_URL" ]; thenexport DIRECT_URL=$DATABASE_URLfi+prisma db execute --url "$DIRECT_URL" --file "./packages/shared/scripts/cleanup.sql"+# Apply migrationsprisma migrate deploy --schema=./packages/shared/prisma/schema.prismastatus=$?