SQL Schema and migrations for ManageIQ.
See the section on plugins in the ManageIQ Developer Setup
For quick local setup run bin/setup, which will clone the core ManageIQ repository under the spec directory and setup necessary config files. If you have already cloned it, you can run bin/update to bring the core ManageIQ code up to date.
This repository contains customizations requiring some changes from the default Rails Schema Dumper. The schema dumper should produce a schema.rb that when loaded will create an identical schema to the one produced by running the migrations through rake db:migrate. To verify the schema dumper is working correctly, you can do the following:
- Verify each of these steps produce an identical
schema.rbfound inspec/dummy/db/schema.rb:
rm -f spec/dummy/db/schema.rb; REGION=0 TEST_RAILS_VERSION='8.0' RAILS_ENV=test bundle exec rake app:db:drop app:db:create app:db:migrate
rm -f spec/dummy/db/schema.rb; REGION=0 TEST_RAILS_VERSION='8.0' RAILS_ENV=test bundle exec rake app:db:drop app:db:create app:db:migrate app:db:schema:dump
rm -f spec/dummy/db/schema.rb; REGION=0 TEST_RAILS_VERSION='8.0' RAILS_ENV=test bundle exec rake app:db:drop app:db:create app:db:migrate; REGION=0 TEST_RAILS_VERSION='8.0' RAILS_ENV=test bundle exec rake app:db:schema:dumpNote, the second and third examples are testing that global state is not being carried over between runs as db:migrate does a db:schema:dump so the second example does two separate dump commands. The final one verifies it also works as separate commands.
- Verify the
schema.rbgenerated above is loaded successfully into the database, can then be dumped, and the dumpedschema.rbis identical to the ones generated above:
REGION=0 TEST_RAILS_VERSION='8.0' RAILS_ENV=test bundle exec rake app:db:drop app:db:create app:db:schema:load app:db:schema:dump- Verify the database created from
app:db:migrateabove is identical to the one fromapp:db:schema:loadfrom the previous step. Use tools such as pgAdmin 4's tools -> schema diff to verify the databases are identical.
Unlike other ManageIQ plugins, the schema plugin uses a dummy application in spec/dummy instead of the usual spec/manageiq. This ensures that schema migrations are not dependent on any models or files in ManageIQ core.
To run the tests:
- If necessary, copy
spec/dummy/config/database.tmpl.ymltospec/dummy/config/database.ymland modify it to access your local database - Run:
bin/setup- Copies
spec/dummy/config/database.tmpl.ymltospec/dummy/config/database.ymlif it doesn't exist - Performs
bundle update - Generates random database region number
- Creates/resets
dummy_testdatabase
- Copies
- Run:
rspec spec/migrations/<spec_file>orrake(Run all migration tests)
The gem is available as open source under the terms of the Apache License 2.0.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request