Jacob Miller
Jacob Miller

Reputation: 560

Is loading structure.sql using rake an atomic transaction?

Is loading structure.sql via rake atomic?

If I load structure.sql using this command and it fails because of an error within the structure.sql file:

$ bundle exec rake db:schema:load RAILS_ENV=test

psql:/path/to/app/db/structure.sql:13342: ERROR:  column "column_id" does not exist
rake aborted!
failed to execute:
psql --set ON_ERROR_STOP=1 --quiet --no-psqlrc --output /dev/null --file /path/to/app/db/structure.sql test

Please check the output above for any errors and make sure that `psql` is installed in your PATH and has proper permissions.

/Users/jmiller/.rbenv/versions/2.7.6/bin/bundle:23:in `load'
/Users/jmiller/.rbenv/versions/2.7.6/bin/bundle:23:in `<main>'
Tasks: TOP => db:schema:load
(See full trace by running task with --trace)

and then attempt to rerun after resolving the error, it fails again due to an existing enum type that is defined within structure.sql:

$ bundle exec rake db:schema:load RAILS_ENV=test 

psql:/path/to/app/db/structure.sql:33: ERROR:  type "status" already exists
rake aborted!
failed to execute:
psql --set ON_ERROR_STOP=1 --quiet --no-psqlrc --output /dev/null --file /path/to/app/db/structure.sql test

Please check the output above for any errors and make sure that `psql` is installed in your PATH and has proper permissions.

/Users/jmiller/.rbenv/versions/2.7.6/bin/bundle:23:in `load'
/Users/jmiller/.rbenv/versions/2.7.6/bin/bundle:23:in `<main>'
Tasks: TOP => db:schema:load
(See full trace by running task with --trace)

This enum type could only exist if the structure.sql got loaded in some capacity, and therefore suggests that it is a non-atomic transaction. Is there documentation for this?

Upvotes: 2

Views: 81

Answers (0)

Related Questions