Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a Sequel migration from an existing postgres table dump?

I am wondering the best way to create a migration in sequel that is based on an existing table dump from postgres. I realise that I will have to write the down method myself to remove the table / functions / sequences, but is there a way to tell the sequel up migration to load an existing sql script and execute everything in the script?

Edit: Just in case its unclear, this is using the ruby Sequel SQL library / gem

like image 314
kelso Avatar asked Mar 27 '26 10:03

kelso


1 Answers

You wouldn't create a migration from a table dump, but you can easily create one by using Sequel's schema_dumper extension. There's actually built-in support for this in the sequel command line program:

sequel -d postgres://postgres@localhost/mydb > 001_initial_migration.rb

There's no support for dumping functions or sequences, as this is designed to produce a database-independent migration.

If you are using functions and custom sequences, you are fully in database-specific territory, and may be better off just using the database's tools.

like image 79
Jeremy Evans Avatar answered Mar 30 '26 10:03

Jeremy Evans



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!