mansueli / Supa-Migrate

Migrating schema & data between supabase projects
Apache License 2.0
37 stars 3 forks source link

Didn't migrate any data #11

Open belle-chang opened 9 months ago

belle-chang commented 9 months ago

Hi,

I'm using your COLAB notebook for Migrate_Project_&_Storage.ipynb, but none of my data is actually copying to my tables in my new Supabase project. Is there anything I could be missing?

Thanks!

mansueli commented 9 months ago

Hey @belle-chang, can you share the logs that you got?

Either the logs file or the output after running the last part of the colab.

belle-chang commented 9 months ago

Hey! I realized what the issue was - it's not doing any of the insertions because I had some key constraints and relationships in my DB. I had to add this to the beginning of the script:

# Create a temporary file to store the modified data dump
tmpfile=$(mktemp)

# Insert the line at the beginning of the data_dump.sql file
# This is NECESSARY -- it allows insertion even if there are key constraints
echo 'SET session_replication_role = replica;' > "$tmpfile"
mv "$tmpfile" data_dump.sql

Alternatively you can manually add SET session_replication_role = replica; to the beginning of the data_dump.sql file. Then, when saving to data_dump.sql, I used >>.

belle-chang commented 9 months ago

Sorry, another question. I'm noticing that not all my storage objects are being moved over with the script. I am only getting about 270 of the 2300 records in my table I'm trying to back up. Is there something I'm missing here? The policies for the table are on anon.

mansueli commented 9 months ago

Thanks for getting back to us. I am not sure, can you edit the script to be in debug mode?

Add a block with this code below above the block Running migration & moving storage objects: and run it:

!pip install logging
from logging import basicConfig, DEBUG
basicConfig(level=DEBUG)

Then, you'll be able to get more verbose logs to understand what is happening there.