Skip to content

supabase db reset seems to try seeding before schema is run #2194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rookledookle opened this issue Apr 22, 2024 · 2 comments
Closed

supabase db reset seems to try seeding before schema is run #2194

rookledookle opened this issue Apr 22, 2024 · 2 comments

Comments

@rookledookle
Copy link

Describe the bug
Hello! New to supabase here, sorry if I'm missing something obvious.

I'm encountering an issue where I get an error failed to send batch: ERROR: relation "public.signs" does not exist (SQLSTATE 42P01) when I run supabase db reset

My goal: replicate the db I have in supabase remote locally, so that I can test my edge functions which rely on transforming existing data in my db.

In my schema.sql file there is the following code which seems to me that the table should exist

CREATE TABLE IF NOT EXISTS "public"."signs" (
    "name" "text" NOT NULL,
    "unicode_name" "text" NOT NULL,
    "symbol" "text",
    "emoji" "text",
    "html_code" "text",
    "unicode_code" "text",
    "id" bigint NOT NULL,
    "created_at" timestamp with time zone DEFAULT ("now"() AT TIME ZONE 'utc'::"text") NOT NULL,
    "updated_at" timestamp with time zone
);

Another interesting thing is when I redo all the steps, I get errors for different tables, for example, I got a different error doing the same steps failed to send batch: ERROR: relation "public.charts" does not exist (SQLSTATE 42P01). I have a hypothesis that it's trying to seed the data before the schema is done setting up and doing it at various points so it sometimes can/ cannot find these tables.

To Reproduce
Here's the steps I did:

  • supabase db dump -f supabase/schema.sql
  • supabase db dump -f supabase/seed.sql --data-only
  • supabase stop
  • supabase start
  • supabase db reset

Expected behavior
local db is reset and seeded with the data in seed.sql

System information
Crash ID: 98b183488ad74c1c86347586c36ade20

Additional context

  • supabase cli version 1.162.4 (I just upgraded it today before logging this)
@sweatybridge
Copy link
Contributor

sweatybridge commented Apr 22, 2024

Currently supabase/schema.sql isn't used by CLI but we have an open PR to address this.

The workaround is to move it under supabase/migrations. For eg.

mkdir -p supabase/migrations
mv supabase/schema.sql supabase/migrations/0_schema.sql

@rookledookle
Copy link
Author

@sweatybridge wow - thank you so much for the quick reply! that worked for me! lifesaver 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants