Answer the question
In order to leave comments, you need to log in
Migration -> change_table -> bulk not working?
Hello. Windows 10 x64, Rails 5.1.3, Ruby 2.4.1p111 (2017-03-22 revision 58053) [x64-mingw32], PostgreSQL .6
Don't tell me why the :bulk option in change_table does not work in migrations
class Test2 < ActiveRecord::Migration[5.1]
def change
change_table :testes, { bulk: true } do |t|
t.string :test1, :test2, :test3, limit: 3
t.string :test4, limit: 3
end
end
end
(1.0ms) BEGIN
(0.5ms) ALTER TABLE "testes" ADD "test1" character varying(3)
(0.5ms) ALTER TABLE "testes" ADD "test2" character varying(3)
(0.5ms) ALTER TABLE "testes" ADD "test3" character varying(3)
(0.5ms) ALTER TABLE "testes" ADD "test4" character varying(3)
SQL (0.5ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"
(0.5ms) COMMIT
alter table testes add column test1 varchar(3), add column test2 varchar(3), add column test3 varchar(3), add column test4 varchar(3)
Answer the question
In order to leave comments, you need to log in
postgresql base?
If you look at the rails code for change_table , you can see that rails checks the supports_bulk_alter? condition defined in abstrtact_adapter and returns false. There is an override for mysql , while pg does not override this method
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question