Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

db:structure:dump is exporting the rails schema, not sql #32

Open
matttarantino opened this issue May 17, 2023 · 2 comments
Open

db:structure:dump is exporting the rails schema, not sql #32

matttarantino opened this issue May 17, 2023 · 2 comments

Comments

@matttarantino
Copy link

Hello! I am working on getting our brillo process working again, and I am running into an issue, although I might be misunderstanding something.

When I run the scrub with recreate_db: false, the scrub only contains SQL insert statements as expected. To refresh my local DB, I perform the following, and everything works:

db:drop
db:create
db:schema:load (which creates the structure in the DB)
db:load (which only runs the insert statements)

However when I run the scrub with recreate_db: true, the scrub also contains the schema at the top of the file. To refresh my local DB, I should only have to run rake db:load as this should drop, create, and load both the schema + data. What I am seeing is that this process never does a db:schema:load so the tables are never getting created in the local DB. When it loads the data, the DB is empty so the insert statements aren't really doing anything. If I run db:schema:load and then db:load, it drops the DB (given the logic in recreate_db) so there is no way to db:schema:load before this process.

Am I missing something here?

@matttarantino
Copy link
Author

Additionally, it seems that recreate_db is true by default, which means that this doesn't work by default until you disable recreate_db. I am also confused on why including the schema in the dump is helpful, since running db:schema:load would pull from your local codebase anyways.

@matttarantino
Copy link
Author

Aha, it does a db:structure:dump here, not a db:schema:dump. This is supposed to export the schema as sql, but because of this deprecation in rails, the process is including the rails schema in the file instead of sql, thus explaining why its not loading the schema properly. I'll try to make a PR that sets the schema_format before running db:structure:dump so that it outputs properly.

Until then, it seems the only way to get this process to work correctly is to set recreate_db: false and load the schema manually like I did in my initial attempt.

@matttarantino matttarantino changed the title Question on recreate_db not loading schema db:structure:dump is exporting the rails schema, not sql May 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant