On Wednesday, February 24, 2016 at 3:14:21 PM UTC-8, Giovanni K Bonetti wrote: > > Hi, there! > > I have been using the Schema Dumper extension, and I was wondering if I > could do the reverse operation: load the schema from file. > > I realized that the schema dump file works just like a migration, so I can > find a way to use it like one. > > Does Sequel have any helper functions for that like in Active Record? > > I want to do something like: > > rake db:schema:dump[database_name] > rake db:schema:load[database_name] > > It would be great if it would automatically populate the "schema_info" > table as well. >
Sequel doesn't have helper functions to do exactly what you want. The bin/sequel tool can dump migrations (-d and -D), and run migrations (-m), but the schema_info/schema_migrations table is not handled automatically, you'd probably have to remove it from the dumped migration before running it. Can you explain your use case for this? If you already have a schema_info/schema_migrations table, you are probably already using migrations, and therefore I'm not sure why you'd want to do this. The schema dumper can be used to take a database that hasn't used migrations in the past, and setup an initial migration to use in the future. I should warn you that the schema_dumper is fairly limited. If you are doing anything at all complex in your database (functions, triggers, partial/functional indexes, etc.), a database created from a Sequel-dumped schema would probably not have schema identical to the original database. Thanks, Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
