Local <--> Remote Migrations Help
I'm running into some issues with writing migrations.
I want to insert some data into the db to test a few features.
I want this data to be both on production database AND the local database.
So I'm doing this:
insert into companions (name, bio, avatar_url, created_by)
values ('Rio', 'lorem ispum', '/rio.jpg', '85331156-96c5-4f28-807a-6ab7b347d065')
returning id
)
insert into chats(user_id, companion_id) select '85331156-96c5-4f28-807a-6ab7b347d065', id from inserted_companion;
commit;
sh
echo "SET session_replication_role = replica;" >> supabase/seed.sql
supabase db dump --data-only >> supabase/seed.sql
I want to insert some data into the db to test a few features.
I want this data to be both on production database AND the local database.
So I'm doing this:
- Writing a miration to insert the data
```sql
-- Insert a new companion and chat for testing purposes
begin;
insert into companions (name, bio, avatar_url, created_by)
values ('Rio', 'lorem ispum', '/rio.jpg', '85331156-96c5-4f28-807a-6ab7b347d065')
returning id
)
insert into chats(user_id, companion_id) select '85331156-96c5-4f28-807a-6ab7b347d065', id from inserted_companion;
commit;
sh
echo "SET session_replication_role = replica;" >> supabase/seed.sql
supabase db dump --data-only >> supabase/seed.sql
``
- However, the problem I'm encountering is that the migration that inserts the data will still cause conflicts when running supabase db reset`.- Fundementally, it seems like this is because the environments of the remote and local are different.
- The remote db already has seed data before running the latest migration
- But the local db has to run all migration first before seeding data.
- This leads to issues like the one I'm encountering.