aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/schema_dumper.rb
Commit message (Collapse)AuthorAgeFilesLines
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* Use mattr_accessor default: option throughout the projectGenadi Samokovarov2017-06-031-2/+1
|
* Update SchemaDumper.ignore_tables docsGuillermo Iguaran2017-05-151-2/+2
|
* Tweaks #28678Ryuta Kamizono2017-04-091-4/+5
| | | | | | * Fix the comment on `formatted_version` * Extract `define_params` * Remove duplicated guard clause for `@version`
* use formatted number as schema versionAnton Chuchkalov2017-04-051-1/+9
|
* Use `tables` instead of `data_sources - views`Ryuta Kamizono2017-02-281-1/+1
| | | | `tables` returns only tables now.
* Add `default_index_type?` to the generic schema dumper doesn't have the ↵Ryuta Kamizono2017-02-141-1/+1
| | | | knowledge about an index type
* Omit redundant `using: :btree` for schema dumpingRyuta Kamizono2017-02-131-1/+1
|
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-2/+2
|
* Extract `format_colspec` to format column specRyuta Kamizono2016-10-111-9/+9
|
* Fix table comment dumpingRyuta Kamizono2016-10-111-1/+1
| | | | | | | | | | | | | Follow up to #26735. If `table_options` returns `{ comment: nil }`, `create_table` line is broken. Example: ```ruby create_table "accounts", force: :cascade, do |t| ```
* `name` is not a column optionRyuta Kamizono2016-10-101-9/+6
| | | | `migration_keys` includes `name` but `name` is not a column option.
* Dump index options to pretty formatRyuta Kamizono2016-10-101-6/+2
| | | | | | | | | | ```ruby # Before t.index ["firm_id", "type", "rating"], name: "company_index", order: {"rating"=>:desc}, using: :btree # After t.index ["firm_id", "type", "rating"], name: "company_index", order: { rating: :desc }, using: :btree ```
* Prevent to create blank commentRyuta Kamizono2016-10-081-3/+5
| | | | | Currently blank comment does not dump to `db/schema.rb`. But created it even if specified blank.
* Remove unnecessary `format_string`Ryuta Kamizono2016-08-231-15/+2
| | | | | `format_string` is used for standardized column types/arguments spaces. Now the standardization was removed at df84e9867219e9311aef6f4efd5dd9ec675bee5c.
* Remove the SchemaDumper options and change the default behaviorRafael Mendonça França2016-08-221-38/+3
| | | | | Now the schema dumper by default doesn't align the types and arguments in the ruby format anymore.
* Option not to line up column types and attributes in schema.rbTim Petricola2016-08-171-10/+38
|
* Add three new rubocop rulesRafael Mendonça França2016-08-161-3/+3
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* applies new string literal convention in activerecord/libXavier Noria2016-08-061-5/+5
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Merge pull request #25340 from kamipo/prevent_table_comment_queryRafael França2016-07-281-4/+4
|\ | | | | Prevent `table_comment` query if a table doesn't have a comment
| * Prevent `table_comment` query if a table doesn't have a commentRyuta Kamizono2016-06-101-4/+4
| |
* | Move the warning about composite primary key to `AttributeMethods::PrimaryKey`Ryuta Kamizono2016-07-021-6/+1
|/ | | | | | | | | | | Actually schema dumper/creation supports composite primary key (#21614). Therefore it should not show the warning about composite primary key in connection adapter. This change moves the warning to `AttributeMethods::PrimaryKey` and suppress the warning for habtm join table. Fixes #25388.
* Remove magic comment in generated `schema.rb`Ryuta Kamizono2016-05-121-4/+0
| | | | | Rails 5.0 has been dropped Ruby 1.9 support. I think no need magic comment anymore.
* Dump indexes in `create_table` for generates SQL in one queryRyuta Kamizono2016-04-201-20/+33
| | | | | If the adapter supports indexes in create table, it generates SQL in one query.
* Database comments: Treat blank comments as no comment. Don't dump blank ↵Jeremy Daer2016-04-191-1/+1
| | | | comments.
* Database comments: switch to keyword args for new table optionsJeremy Daer2016-04-181-2/+3
| | | | | | * Switch to keyword args where we can without breaking compat. * Use add_table_options! for :options, too. * Some code polish.
* Add support for specifying comments for tables, columns, and indexes.Andrey Novikov2016-04-161-0/+4
| | | | | | | | | | | | | Comments are specified in migrations, stored in database itself (in its schema), and dumped into db/schema.rb file. This allows to generate good documentation and explain columns and tables' purpose to everyone from new developers to database administrators. For PostgreSQL and MySQL only. SQLite does not support comments at the moment. See docs for PostgreSQL: http://www.postgresql.org/docs/current/static/sql-comment.html See docs for MySQL: http://dev.mysql.com/doc/refman/5.7/en/create-table.html
* Merge pull request #24054 from kamipo/extract_default_primary_keyRafael França2016-03-111-1/+1
|\ | | | | Extract `default_primary_key?` to refactor `column_spec_for_primary_key`
| * Extract `default_primary_key?` to refactor `column_spec_for_primary_key`Ryuta Kamizono2016-03-111-1/+1
| |
* | Initialize `column.table_name` immediately for `column.serial?` correctly ↵Ryuta Kamizono2016-03-081-4/+1
|/ | | | | | | | working Currently the results of `column.serial?` is not correct. For `column.serial?` correctly working, initialize `column.table_name` immediately.
* Revert "Dump indexes in `create_table` instead of `add_index`"Sean Griffin2016-02-051-4/+6
| | | | | | | | | | This reverts commit 99801c6a7b69eb4b006a55de17ada78f3a0fa4c1. Ultimately it doesn't matter whether `add_index` or `t.index` are used in the schema dumper in any meaningful way. There are gems out there which hook into the old behavior for things like indexing materialized views. Since the reverted commit doesn't seem to add much benefit, there's no reason for us to break these gems.
* Prevent destructive action on production databaseschneems2016-01-071-1/+1
| | | | | | | This PR introduces a key/value type store to Active Record that can be used for storing internal values. It is an alternative implementation to #21237 cc @sgrif @matthewd. It is possible to run your tests against your production database by accident right now. While infrequently, but as an anecdotal data point, Heroku receives a non-trivial number of requests for a database restore due to this happening. In these cases the loss can be large. To prevent against running tests against production we can store the "environment" version that was used when migrating the database in a new internal table. Before executing tests we can see if the database is a listed in `protected_environments` and abort. There is a manual escape valve to force this check from happening with environment variable `DISABLE_DATABASE_ENVIRONMENT_CHECK=1`.
* introduce `conn.data_source_exists?` and `conn.data_sources`.Yves Senn2015-09-221-1/+1
| | | | | | | | | | | | | | | | | These new methods are used from the Active Record model layer to determine which relations are viable to back a model. These new methods allow us to change `conn.tables` in the future to only return tables and no views. Same for `conn.table_exists?`. The goal is to provide the following introspection methods on the connection: * `tables` * `table_exists?` * `views` * `view_exists?` * `data_sources` (views + tables) * `data_source_exists?` (views + tables)
* Merge pull request #21609 from kamipo/do_not_dump_view_as_tableJeremy Daer2015-09-191-1/+1
|\ | | | | | | Do not dump a view as a table in sqlite3, mysql and mysql2 adapters
| * Do not dump a view as a table in sqlite3, mysql and mysql2 adaptersRyuta Kamizono2015-09-131-1/+1
| | | | | | | | | | | | Now in sqlite3, mysql and mysql2 adapters, SchemaDumper dump a view as a table. It is incorrect behavior. This change excludes a view in schema.rb.
* | Correctly dump composite primary keyRyuta Kamizono2015-09-201-6/+13
| | | | | | | | | | | | | | | | | | Example: create_table :barcodes, primary_key: ["region", "code"] do |t| t.string :region t.integer :code end
* | Don't hardcode table nameschneems2015-09-161-1/+1
|/ | | | | The schema_migrations table name is configurable. We should use this value when checking for ignored table names when dumping schema instead of a hardcoded value.
* Remove unused already requireRyuta Kamizono2015-05-191-1/+0
|
* Merge pull request #19994 from kamipo/dump_indexes_in_create_tableRafael Mendonça França2015-05-031-6/+4
|\ | | | | | | Dump indexes in `create_table` instead of `add_index`
| * Dump indexes in `create_table` instead of `add_index`Ryuta Kamizono2015-05-031-6/+4
| | | | | | | | | | If the adapter supports indexes in create table, generated SQL is slightly more efficient.
* | Correctly dump `:options` on `create_table` for MySQLRyuta Kamizono2015-05-031-0/+4
|/
* Add `:charset` and `:collation` options support for MySQL string and text ↵Ryuta Kamizono2015-03-061-1/+4
| | | | | | | | | | | columns Example: create_table :foos do |t| t.string :string_utf8_bin, charset: 'utf8', collation: 'utf8_bin' t.text :text_ascii, charset: 'ascii' end
* Improve a dump of the primary key support.Ryuta Kamizono2014-12-291-5/+6
| | | | If it is not a default primary key, correctly dump the type and options.
* Dump the default `nil` for PostgreSQL UUID primary key.Ryuta Kamizono2014-12-261-1/+1
|
* `force: :cascade` to recreate tables referenced by foreign-keys.Yves Senn2014-12-191-1/+1
|
* no need to pass native_database_types aroundYves Senn2014-12-021-2/+1
|
* Remove is_a? check when ignoring tablesSean Griffin2014-11-201-6/+1
| | | | | Technically changes the API, as it will allow any object which responds to `===`. Personally, I think this is more flexible.
* add bigserial pk supportAaron Patterson2014-10-291-0/+2
|
* do not dump foreign keys for ignored tables.Yves Senn2014-09-171-1/+1
|