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

Some changes to hopefully make generating structure.sql easier. #4405

Merged
merged 1 commit into from Aug 4, 2019

Conversation

jfly
Copy link
Contributor

@jfly jfly commented Aug 4, 2019

When running bin/rake db:structure:dump, I get two lines of diff in my
structure.sql file:

  1. Some trailing space is added to a CREATE VIEW declaration.
    • This is pretty harmless, but it is annoying to remove each time.
  2. A DEFINER= line gets added before our rails_persons VIEW.
    • This one regularly causes pain, as it breaks bin/rake db:reset
      for some reason.

This diff changes things so we remove these changes when dumping the
database schema.

@@ -1341,6 +1341,7 @@ CREATE TABLE `wcif_extensions` (
/*!50001 SET character_set_results = utf8mb4 */;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly this doesn't seem to happen for me:

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you asking why there's a blank space here on line 1344? That's because with these changes, we're now gsub-ing away the DEFINER= line, which leaves behind a blank line. It might be possible to get rid of the blank line (doing a multiline regex? something else?), but it seemed like it would be extra work with no real benefit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah gotcha! I believe it should be as simple as specifying \n instead of line start ^. I'm happy with either version, just wanted to ensure that I won't run into other weird diff locally =)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh dang, I wasn't expecting that to work, I thought I'd need to enable multiline regexes somehow...

Changed! Now there is no diff to structure.sql =)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the only difference with multiline regexps is that . additionally match newline characters, but you can always use them explicitly =)

Copy link
Member

@jonatanklosko jonatanklosko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

When running `bin/rake db:structure:dump`, I get two lines of diff in my
`structure.sql` file:
1. Some trailing space is added to a `CREATE VIEW` declaration.
   - This is pretty harmless, but it is annoying to remove each time.
2. A `DEFINER=` line gets added before our `rails_persons` `VIEW`.
   - This one regularly causes pain, as it breaks `bin/rake db:reset`
     for some reason.

This diff changes things so we remove these changes when dumping the
database schema.
@jfly jfly merged commit a605db1 into thewca:master Aug 4, 2019
@jfly jfly deleted the easier-db-dumps branch August 4, 2019 23:42
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

Successfully merging this pull request may close these issues.

None yet

2 participants