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

Fixes #33008 - switch to sql schema dumping #8660

Merged
merged 1 commit into from Jul 22, 2021

Conversation

jlsherrill
Copy link
Contributor

No description provided.

@theforeman-bot
Copy link
Member

Issues: #33008

@@ -1,2 +1,2 @@
# Ignore Dynflow tables when schema-dumping. Dynflow tables are handled automatically by Dynflow.
ActiveRecord::SchemaDumper.ignore_tables << /^dynflow_.*$/
ActiveRecord::SchemaDumper.ignore_tables << '^dynflow_*'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not 100% sure about this, the docs seem to indicate that '^dynflow_*$' should work, but it didn't seem to and allowed everything through. '^dynflow_*' appeared to work fine:

$ grep dynflow_ db/structure.sql 
    dynflow_execution_plan_id character varying,
    dynflow_step_id integer,

Copy link
Member

Choose a reason for hiding this comment

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

This actually does NOT work and is a regression. When I do rake db:schema:dump it creates me Ruby version (schema.rb) and it does contain dynflow tables. This leads to the issue: https://projects.theforeman.org/issues/30052

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

@tbrisker thoughts on merging this so it gets in 3.0?

Copy link
Member

@tbrisker tbrisker left a comment

Choose a reason for hiding this comment

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

Thanks @jlsherrill ! let's get this in to 3.0, hopefully it won't break anything.

@tbrisker tbrisker merged commit 99c385d into theforeman:develop Jul 22, 2021
@lzap
Copy link
Member

lzap commented Aug 25, 2021

I am seeing this file as modified all the time, shall we add it into .gitignore just like we did with db/schema.rb?

@lzap
Copy link
Member

lzap commented Oct 7, 2021

How this is supposed to work? When I do rake db:schema:dump on develop today, it creates config/schema.rb. I don't see any SQL generated.

@lzap
Copy link
Member

lzap commented Oct 7, 2021

Oh I understand, it creates both db/schema.rb AND db/structure.sql. Is this expected? What format should rails "load" pick?

@lzap
Copy link
Member

lzap commented Oct 7, 2021

Looks like Ruby codebase explains it nicely.

    ##
    # :singleton-method:
    # A list of tables which should not be dumped to the schema.
    # Acceptable values are strings as well as regexp if ActiveRecord::Base.schema_format == :ruby.
    # Only strings are accepted if ActiveRecord::Base.schema_format == :sql.
    cattr_accessor :ignore_tables, default: []

    ##
    # :singleton-method:
    # Specify a custom regular expression matching foreign keys which name
    # should not be dumped to db/schema.rb.
    cattr_accessor :fk_ignore_pattern, default: /^fk_rails_[0-9a-f]{10}$/

    ##
    # :singleton-method:
    # Specify a custom regular expression matching check constraints which name
    # should not be dumped to db/schema.rb.
    cattr_accessor :chk_ignore_pattern, default: /^chk_rails_[0-9a-f]{10}$/

@lzap
Copy link
Member

lzap commented Oct 7, 2021

I have found out that regular expression works both for SQL and Ruby however regexp in a string only works for SQL. Filing an issue and a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants