In a previous migration, I defined:
create table(:my_table) do
add :reference_id, references(:references), null: false
(...)
end
Now I want to remove the reference and the null: false
, but still keep the reference_id
field.
So I want something like:
alter table(:my_table) do
modify :reference_id, <SOME_TYPE>, null: true
end
My DB is Postgres, so I think should be :bigint.
I have two questions:
- Is the above correct?
- If I understand correctly, this migration cannot be rolled back directly, so I have to create up
and down
functions. If that code is in the up
of my migration, what should go in the down
?