I want to change a column type from :string
to :text
The problem is that if I simply do:
change_column :questions, :content, :text
Then the schema is rewritten to:
t.string "content", :limit => 255
i.e. it takes the length that was implicit when it was a string
How can I do the migration and specify that the :limit
should not be set such that the schema reads:
t.string "content"
I have tried setting an arbitrary limit of 10,000 but a) that feels inefficient and b) it makes the down migration attempt to set the :text
limit to 10,000.
What option can I pass to the change_column
method to ensure it simply uses the default limit?
Supposing that the column was of type DataTypes. STRING , we would do: await queryInterface. changeColumn('User', 'ip', { type: Sequelize.
First, specify the name of the table to which the column you want to change belongs in the ALTER TABLE clause. Second, give the name of column whose data type will be changed in the ALTER COLUMN clause. Third, provide the new data type for the column after the TYPE keyword.
Ack, discovered this by trial and error moments after posting the question:
change_column :questions, :content, :text, :limit => nil
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With