ronin-rb / ronin-db-activerecord

ActiveRecord backend for the Ronin Database
https://ronin-rb.dev
GNU Lesser General Public License v3.0
7 stars 5 forks source link

Add the ability to initialize a new database using a schema dump file #5

Closed postmodern closed 2 years ago

postmodern commented 2 years ago

Instead of running all of the migrations to provision a new database, load a schema dump file.

Example code for dumping and loading the schema: https://github.com/rails/rails/blob/4388275c48d4dda2d59fefc0cb89248b4b037a34/activerecord/lib/active_record/tasks/database_tasks.rb

postmodern commented 2 years ago

A couple of problems with this approach:

  1. If we dump the schema in SQL then it is specific to the database's SQL dialect which generated the dump.
  2. If we dump the schema in Ruby, then it essentially runs a migration for every table.
  3. It does not seem to update ronin_schema_migrations or schema_migrations indicating that the database has been fully updated to a given migration version.