cli icon indicating copy to clipboard operation
cli copied to clipboard

Deduplication of declarative schemas fail on Windows

Open cohlar opened this issue 6 months ago • 3 comments

Describe the bug I have created the below declarative schema structure.

Image

I have added the below schema paths to my config.toml:

[db.migrations]
schema_paths = [
  "schemas/enums.sql",
  "schemas/tables/abstract/baseModel.sql",
  "schemas/tables/abstract/*.sql",
  "schemas/tables/**/*.sql"
]

When running yarn supabase db diff -f whatever, I get the below log:

Creating local database from declarative schemas:
 • supabase/schemas/enums.sql
 • supabase/schemas/tables/abstract/baseModel.sql
 • supabase\schemas\tables\abstract\baseDocuments.sql
 • supabase\schemas\tables\abstract\baseModel.sql
 • supabase\schemas\tables\abstract\baseProduct.sql
 • supabase\schemas\tables\public\sellers.sql
Initialising schema...
Seeding globals from roles.sql...
Seeding globals from enums.sql...
Seeding globals from baseModel.sql...
Seeding globals from baseDocuments.sql...
Seeding globals from baseModel.sql...

In my case the script fails when re-applying baseModel.sql a second time (it tries to re-create the same table).

Expected behavior supabase/schemas/tables/abstract/baseModel.sql should only be run once, not twice.

System information

  • Ticket ID: fb17c4aebea84fa0b9132c7327d8dc5d
  • Version of OS: Windows 11 Pro 24H2
  • Version of CLI: 2.22.6
  • Version of Docker: Docker Windows Desktop 4.41.0 (engine 28.1.1)
  • Versions of services:
SERVICE IMAGE          | LOCAL                  | LINKED
 ------------------------|------------------------|------------
  supabase/postgres      | 15.8.1.044             | 15.8.1.044
  supabase/gotrue        | v2.170.0               | v2.172.1
  postgrest/postgrest    | v12.2.3                | v12.2.3
  supabase/realtime      | v2.34.47               | -
  supabase/storage-api   | v1.22.11               | -
  supabase/edge-runtime  | v1.67.4                | -
  supabase/studio        | 2025.05.05-sha-3c3fe9b | -
  supabase/postgres-meta | v0.88.9                | -
  supabase/logflare      | 1.12.0                 | -
  supabase/supavisor     | 2.5.1                  | -

Additional context This feels like a Windows related issue with the / and \ (I suspect this doesn't happen on macOS or Linux, but haven't verified). I can fix this in a number of ways for myself (e.g. make baseModel.sql idempotent, or describe schema_paths more explicitly, or rename my schemas to ensure they are executed in the right order by default), but this seems like a bug to me and I thought it's worth raising it.

cohlar avatar May 12 '25 11:05 cohlar

Experiencing this issue as well. I'm just going to manually specify the schema path for each file for now. Prefer not to do this for too long.

jandreasian avatar May 31 '25 21:05 jandreasian

Same issue

JTCorrin avatar Jun 08 '25 07:06 JTCorrin

I'm also experiencing this issue and while specifying each file individually works it's not a good long term solution.

olefritsch avatar Jun 22 '25 21:06 olefritsch

This should be fixed in the latest release. Feel free to reopen if the issue persists.

sweatybridge avatar Jul 02 '25 09:07 sweatybridge

Applied the change the same day it was fixed. Worked great! Thank you.

jandreasian avatar Jul 02 '25 14:07 jandreasian