aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/schema_dumper.rb
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
|
* Schema dumper: all connection adapters implement #primary_key, so rely on it ↵Jeremy Kemper2014-09-071-10/+1
| | | | exclusively
* Fix warnings for undefined local variableTee Parham2014-09-071-6/+10
| | | | | * Add private method primary_key_for, which more clearly shows that the expected return value is nil when a primary key is not found.
* Prefer "if any?" to "unless empty?"Tee Parham2014-09-071-9/+6
| | | | | * Consistent whitespace * Remove unnecessary parentheses
* Convert string concatenations to substitutionsTee Parham2014-09-071-15/+15
|
* Extract iterator method in AR::SchemaDumperCaleb Thompson2014-07-251-10/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Gems which wish to tie into ActiveRecord::SchemaDumper need to duplicate this logic currently. [Foreigner] is one such example, as is a library I'm currently working on but which hasn't been released yet: def tables_with_foreign_keys(stream) tables_without_foreign_keys(stream) @connection.tables.sort.each do |table| next if ['schema_migrations', ignore_tables].flatten.any? do |ignored| case ignored when String; table == ignored when Regexp; table =~ ignored else raise StandardError, 'ActiveRecord::SchemaDumper.ignore_tables accepts an array of String and / or Regexp values.' end end foreign_keys(table, stream) end end [Foreigner]: https://github.com/matthuhiggins/foreigner/blob/master/lib/foreigner/schema_dumper.rb#L36-L43 Extract the skip logic to a method, making it much simpler to follow this same behavior in gems that are tying into the migration flow and let them dump only tables that aren't skipped without copying this block of code. The above code could then be simplified to: def tables_with_foreign_keys(stream) tables_without_foreign_keys(stream) @connection.tables.sort.each do |table| foreign_keys(table, stream) unless ignored?(table) end end It also, in my opinion, simplifies the logic on ActiveRecord's side, and clarifies the intent of the skip logic.
* Dump PostgreSQL primary key with custom function as a default.Andrey Novikov2014-07-111-1/+2
| | | | | | | | | | | For example, if use pgcrypto extension in PostgreSQL 9.4 beta 1, where uuid-ossp extension isn't available for moment of writing, and thus to use a gen_random_uuid() method as a primary key default. In this case schema dumper wasn't able to correctly reconstruct create_table statement and lost primary key constraint on schema load. Fixes #16111.
* fk: use random digest namesYves Senn2014-06-261-3/+13
| | | | | | The name of the foreign key is not relevant from a users perspective. Using random names resolves the urge to rename the foreign key when the respective table or column is renamed.
* fk: dump foreign keys at the bottom to make sure tables exist.Yves Senn2014-06-261-6/+9
|
* fk: support for on_updateYves Senn2014-06-261-0/+1
|
* fk: rename `dependent` to `on_delete`Yves Senn2014-06-261-1/+1
|
* fk: support dependent option (:delete, :nullify and :restrict).Yves Senn2014-06-261-0/+2
|
* fk: dump foreign keys to schema.rbYves Senn2014-06-261-0/+22
| | | | respect `table_name_prefix` and `table_name_suffix`.
* Push default_function to superclass to avoid method checkRafael Mendonça França2013-10-141-1/+1
|
* Dump the default function when the primary key is uuidRafael Mendonça França2013-10-141-0/+1
| | | | Fixes #12489
* Creating options for schema dumper.wangjohn2013-08-221-5/+16
| | | | | These options make it easier to change the config from ActiveRecord::Base to use something else inside of the SchemaDumper.
* Make SchemaDumper emit "id: :uuid" when appropriate. Fixes #10451.Brian Buchanan2013-05-031-1/+4
|
* Add support for FULLTEXT and SPATIAL indexes using the :type flag for MySQL.Ken Mazaika2013-03-271-0/+2
|
* Dump the 'using' options for a SQL index into the schema.Ken Mazaika2013-03-271-0/+2
|
* Created a layer of abstraction for the valid type checking in schema dumper. ↵Ranjay Krishna2013-03-251-1/+1
| | | | Now, connection handles the check for valid types so that each database can handle the changes individually.
* Revert "checking in the abstractions for valid type checking:"Jon Leighton2013-02-151-1/+1
| | | | | | | | | | | | | | | | This reverts commit c321b309a9a90bbfa0912832c11b3fef52e71840. Conflicts: activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb Reason: failing test 1) Error: test_valid_column(ActiveRecord::ConnectionAdapters::SQLite3AdapterTest): NoMethodError: undefined method `column' for test/cases/adapters/sqlite3/sqlite3_adapter_test.rb:29:in `test_valid_column'
* Merge pull request #9204 from ranjaykrishna/col-probAaron Patterson2013-02-121-1/+1
|\ | | | | schema dumper tests now conducted by ActiveRecord::Base.Connection
| * checking in the abstractions for valid type checking:Ranjay Krishna2013-02-121-1/+1
| |
* | Do not print anything related to extensions when they don't none existCarlos Antonio da Silva2013-02-061-4/+6
| | | | | | | | | | When extensions are supported but there's no one enabled in the database, we should not print anything related to them in schema.rb.
* | Add blank line after extensions to separate from tables in schemaCarlos Antonio da Silva2013-02-061-0/+1
| |
* | Fix indentation of extensions in schemaCarlos Antonio da Silva2013-02-061-4/+2
| |
* | add ActiveRecord::AbstractAdapter#extensions and ↵Justin George2013-02-061-0/+12
|/ | | | ActiveRecord::ConnectionAdapters::PostgreSQLAdapter#extensions to allow dumping of enabled extensions to schema.rb, add ActiveRecord::SchemaDumper#extensions to dump extensions to schema.rb
* Move to the schema-migrations-metadata branch.Jeremy Kemper2012-12-091-16/+5
| | | | | | | | | | | | | | | | | | | | | | | | Pending work on graceful app upgrades. Revert "Merge pull request #8439 from joshsusser/fixes" This reverts commit ce8ac39338f86388e70356b3a470b3ea443802ae, reversing changes made to b0e7b6f67c984d4b1502e801781ed75fad681633. Revert "Merge pull request #8431 from joshsusser/schemadump" This reverts commit 036d3e1c2b65c4b8cbd23de2e20ad67b9b756182, reversing changes made to 0c692f4d121792117b6a71e5ed590a31c3b9d12e. Revert "Merge branch 'joshsusser-master' into merge" This reverts commit 0c692f4d121792117b6a71e5ed590a31c3b9d12e, reversing changes made to 2e299fca715b083a60222a85e48f9d3b8dd8ce93. Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb activerecord/test/cases/schema_dumper_test.rb
* dump schema.rb without :version optionJosh Susser2012-12-051-4/+2
|
* Add migration history to schema.rb dumpJosh Susser2012-12-021-2/+15
|
* Moves column dump specific code to a module included in AbstractAdapterDan McClain2012-09-141-29/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Having column related schema dumper code in the AbstractAdapter. The code remains the same, but by placing it in the AbstractAdapter, we can then overwrite it with Adapter specific methods that will help with Adapter specific data types. The goal of moving this code here is to create a new migration key for PostgreSQL's array type. Since any datatype can be an array, the goal is to have ':array => true' as a migration option, turning the datatype into an array. I've implemented this in postgres_ext, the syntax is shown here: https://github.com/dockyard/postgres_ext#arrays Adds array migration support Adds array_test.rb outlining the test cases for array data type Adds pg_array_parser to Gemfile for testing Adds pg_array_parser to postgresql_adapter (unused in this commit) Adds schema dump support for arrays Adds postgres array type casting support Updates changelog, adds note for inet and cidr support, which I forgot to add before Removing debugger, Adds pg_array_parser to JRuby platform Removes pg_array_parser requirement, creates ArrayParser module used by PostgreSQLAdapter
* Dump schema using new style hashKonstantin Shabanov2012-09-081-10/+10
|
* Merge pull request #4396 from kennyj/fix_4259Rafael Mendonça França2012-06-201-4/+8
|\ | | | | | | Fix GH #4259. When we execute schema dumper, we must remove table_name_prefix and table_name_suffix.
| * Fix GH #4259. We must remove table_name_prefix and table_name_suffix, when ↵kennyj2012-01-101-4/+8
| | | | | | | | we execute schema dumper.