Commit Graph

27 Commits

Author SHA1 Message Date
Zacharias Knudsen
c67e9dfe19
Ensure installed migrations comply with rubocop-rails-omakase
Adds space inside array literal brackets in ActiveStorage/ActionText migrations.

The new `rubocop-rails-omakase` enables `Layout/SpaceInsideArrayLiteralBrackets`,
which failed on the migrations created when installing ActiveStorage and ActionText.
2024-01-04 08:53:23 +01:00
compeak
506e357f00
update migration version from 5.2 to 7.0 2022-09-01 16:54:42 +02:00
piecehealth
ead3f67e88 fix activestorage update 2022-02-10 18:01:09 +08:00
Rafael Mendonça França
8b6342e341
Use if_not_exists instead of table_exists? 2021-12-08 23:25:02 +00:00
Aaron Reisman
6ed63abecd
Update 20191206030411_create_active_storage_variant_records.rb
In the cast of bootstrapping a project for the first time without active storage, when running `rails app:update` this migration would result in trying to create the table twice.
2021-12-03 19:55:01 -08:00
Gannon McGibbon
79a5e0b759 Add ActiveStorage::Blob.compose 2021-11-25 19:37:57 -05:00
Sandip Mane
458d2d3a53 Makes the array syntax consistant with other use cases 2021-08-18 23:44:58 +05:30
fatkodima
753633abdf Respect Active Record's primary_key_type in Active Storage migrations 2021-06-11 11:51:07 +03:00
George Claghorn
2cb84b1847 Add precision to Active Storage timestamps where supported 2021-05-23 14:47:15 -04:00
Santiago Bartesaghi
e61bdbf315
Make Active Storage update migrations reversible 2020-05-07 22:20:16 -04:00
George Claghorn
c9502a33a1 Correct migration name 2019-12-06 13:30:58 -05:00
George Claghorn
7d0327bbbf Track Active Storage variants in the database 2019-12-06 13:26:51 -05:00
Gannon McGibbon
e6487e84fc Make Active Storage services aware of configuration names 2019-10-03 13:08:30 -04:00
DmitryTsepelev
e7f798c3f5 Allow configure services for individual attachments 2019-10-01 21:24:05 +03:00
bogdanvlviv
f2819f7876
Remove AddForeignKeyConstraintToActiveStorageAttachmentsForBlobId migration
In https://github.com/rails/rails/pull/33419, we added this migration to
properly upgrade Active Storage from 5.2 to 6.0

On Rails 6.1 `rails app:update` shouldn't add this migration to users' app.

Note that, I've left implementation that makes `rails app:update` to generate
migrations for users' app that are in `activestorage/db/update_migrate/`
because we are likely to need it e.g.: https://github.com/rails/rails/pull/34935, https://github.com/rails/rails/pull/36835.
2019-08-12 15:37:51 +03:00
Eugeniu Tambur
135d8a0dc1 Traducir del: inglés
44/5000
Checking for the existence of only one table
2019-03-19 13:16:57 +01:00
Eugeniu Tambur
417c625ab2 Fix for migration active_storage migration
*ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR:  relation "active_storage_attachments" does not exist*

Updating to rails 6.0.0.beta3 if the command rake app:update is used a new migration file is generated:

```ruby
# db/migrate/add_foreign_key_constraint_to_active_storage_attachments_for_blob_id.active_storage.rb
class AddForeignKeyConstraintToActiveStorageAttachmentsForBlobId < ActiveRecord::Migration[6.0]
  def up
    unless foreign_key_exists?(:active_storage_attachments, column: :blob_id)
  		add_foreign_key :active_storage_attachments, :active_storage_blobs, column: :blob_id
    end
  end
end
```

**If the project does not have previously installed active storage** this mgiration causes an error:

    ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR:  relation "active_storage_attachments" does not exist

**Error output:**

    PG::UndefinedTable: ERROR:  relation "active_storage_attachments" does not exist
    activerecord-6.0.0.beta3/lib/active_record/connection_adapters/postgresql/database_statements.rb:90:in `async_exec'
    activerecord-6.0.0.beta3/lib/active_record/connection_adapters/postgresql/database_statements.rb:90:in `block (2 levels) in execute'
    activesupport-6.0.0.beta3/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    activesupport-6.0.0.beta3/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    activesupport-6.0.0.beta3/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    activerecord-6.0.0.beta3/lib/active_record/connection_adapters/postgresql/database_statements.rb:89:in `block in execute'
    activerecord-6.0.0.beta3/lib/active_record/connection_adapters/abstract_adapter.rb:643:in `block (2 levels) in log'
    activerecord-6.0.0.beta3/lib/active_record/connection_adapters/abstract_adapter.rb:642:in `block in log'
    activesupport-6.0.0.beta3/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    activerecord-6.0.0.beta3/lib/active_record/connection_adapters/abstract_adapter.rb:633:in `log'
    activerecord-6.0.0.beta3/lib/active_record/connection_adapters/postgresql/database_statements.rb:88:in `execute'
    activerecord-6.0.0.beta3/lib/active_record/connection_adapters/abstract/schema_statements.rb:977:in `add_foreign_key'
    activerecord-6.0.0.beta3/lib/active_record/migration.rb:875:in `block in method_missing'
    activerecord-6.0.0.beta3/lib/active_record/migration.rb:843:in `block in say_with_time'
    activerecord-6.0.0.beta3/lib/active_record/migration.rb:843:in `say_with_time'
    activerecord-6.0.0.beta3/lib/active_record/migration.rb:864:in `method_missing'
    /db/migrate/20190315102607_add_foreign_key_constraint_to_active_storage_attachments_for_blob_id.active_storage.rb:5:in `up'
    activerecord-6.0.0.beta3/lib/active_record/migration.rb:816:in `exec_migration'
    activerecord-6.0.0.beta3/lib/active_record/migration.rb:797:in `block (2 levels) in migrate'
    activerecord-6.0.0.beta3/lib/active_record/migration.rb:796:in `block in migrate'
    activerecord-6.0.0.beta3/lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `with_connection'
    activerecord-6.0.0.beta3/lib/active_record/migration.rb:795:in `migrate'
    activerecord-6.0.0.beta3/lib/active_record/migration.rb:985:in `migrate'
    activerecord-6.0.0.beta3/lib/active_record/migration.rb:1293:in `block in execute_migration_in_transaction'
    activerecord-6.0.0.beta3/lib/active_record/migration.rb:1344:in `block in ddl_transaction'
    activerecord-6.0.0.beta3/lib/active_record/connection_adapters/abstract/database_statements.rb:265:in `block in transaction'
    activerecord-6.0.0.beta3/lib/active_record/connection_adapters/abstract/transaction.rb:272:in `block in within_new_transaction'
    activerecord-6.0.0.beta3/lib/active_record/connection_adapters/abstract/transaction.rb:270:in `within_new_transaction'
    activerecord-6.0.0.beta3/lib/active_record/connection_adapters/abstract/database_statements.rb:265:in `transaction'
    activerecord-6.0.0.beta3/lib/active_record/transactions.rb:212:in `transaction'
    activerecord-6.0.0.beta3/lib/active_record/migration.rb:1344:in `ddl_transaction'
    activerecord-6.0.0.beta3/lib/active_record/migration.rb:1292:in `execute_migration_in_transaction'
    activerecord-6.0.0.beta3/lib/active_record/migration.rb:1264:in `block in migrate_without_lock'
    activerecord-6.0.0.beta3/lib/active_record/migration.rb:1263:in `each'
    activerecord-6.0.0.beta3/lib/active_record/migration.rb:1263:in `migrate_without_lock'
    activerecord-6.0.0.beta3/lib/active_record/migration.rb:1211:in `block in migrate'
    activerecord-6.0.0.beta3/lib/active_record/migration.rb:1364:in `with_advisory_lock'
    activerecord-6.0.0.beta3/lib/active_record/migration.rb:1211:in `migrate'
    activerecord-6.0.0.beta3/lib/active_record/migration.rb:1044:in `up'
    activerecord-6.0.0.beta3/lib/active_record/migration.rb:1019:in `migrate'
    activerecord-6.0.0.beta3/lib/active_record/tasks/database_tasks.rb:191:in `migrate'
    activerecord-6.0.0.beta3/lib/active_record/railties/databases.rake:78:in `block (3 levels) in <main>'
    activerecord-6.0.0.beta3/lib/active_record/railties/databases.rake:76:in `each'
    activerecord-6.0.0.beta3/lib/active_record/railties/databases.rake:76:in `block (2 levels) in <main>'
    railties-6.0.0.beta3/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
    railties-6.0.0.beta3/lib/rails/commands/rake/rake_command.rb:20:in `perform'
    railties-6.0.0.beta3/lib/rails/command.rb:48:in `invoke'
    railties-6.0.0.beta3/lib/rails/commands.rb:18:in `<main>'
    bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
    bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
    bootsnap-1.4.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:83:in `register'
    bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
    bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
    activesupport-6.0.0.beta3/lib/active_support/dependencies.rb:297:in `block in require'
    activesupport-6.0.0.beta3/lib/active_support/dependencies.rb:263:in `load_dependency'
    activesupport-6.0.0.beta3/lib/active_support/dependencies.rb:297:in `require'
    bin/rails:4:in `<main>'
2019-03-15 12:54:42 +01:00
bogdanvlviv
2bad3f46cd
Add foreign key to active_storage_attachments for blob_id via new migration
We need this in order to be able to add this migration for users that
use ActiveStorage during update their apps from Rails 5.2 to Rails 6.0.

Related to #33405

`rake app:update` should update active_storage

`rake app:update` should execute `rake active_storage:update`
if it is used in the app that is being updated.
It will add new active_storage's migrations to users' apps during update Rails.

Context https://github.com/rails/rails/pull/33405#discussion_r204239399

Also, see a related discussion in the Campfire:
https://3.basecamp.com/3076981/buckets/24956/chats/12416418@1236713081
2019-01-16 13:13:23 +00:00
George Claghorn
2ae3a29508 Add a foreign-key constraint to the attachments table for blobs 2018-07-19 20:43:33 -04:00
George Claghorn
9de6c6c91c Widen blob size column 2017-08-24 09:37:04 -04:00
bogdanvlviv
92431ea5fb
Use 5.2 version of ActiveRecord::Migration for Active Storage 2017-08-22 17:32:43 +03:00
bogdanvlviv
43f452f23b
Remove frozen_string_literal comment from activestorage's migration
The activestorage's migration is used as template for apps
Related to #30348
2017-08-22 08:32:27 +03:00
Matthew Draper
4ec5b7610d Merge pull request #30211 from koic/frozen_activestorage
Use frozen string literal in Active Storage
2017-08-13 21:39:38 +09:30
Ryuta Kamizono
4966b36d4c Use references to respect primary key type in active storage tables
If created active storage tables by mysql2 or postgresql adapters, a
primary key is defined as a bigint. It should be used `references` to
the reference columns to respect primary key type.
2017-08-13 13:40:39 +09:00
Koichi ITO
d02844f249 Use frozen string literal in Active Storage 2017-08-12 21:43:42 +09:00
Ryuta Kamizono
d76b2f9e55 Add null: false to Active Storage tables
These columns aren't intended nullable.
2017-08-12 02:33:38 +09:00
Dino Maric
4b72bee47b ActiveStorage:Add migrations per rails engine conventions (#30111)
* Add migrations per rails engine conventions

* Fix failing tests
2017-08-08 09:47:38 -05:00