Say I use Migrate to change `tag: String?` to `ta...
# orm-help
t
Say I use Migrate to change
tag: String?
to
tags: String[]
(changing name + type) how can I make sure that the data is being converted instead of deleted/dropped?
d
Hey Timo, since you are changing the name, I'm not quite sure it would be possible to migrate the data. Maybe a workaround would be creating the new column, making a script to migrate the data and then deleteing the old column. But again, there may be another way of doing it, but I'm not aware of
d
create the migration that drops tag and creates tags, within that script write the sql to move the data before tag is dropped. Then, apply the migration
t
I'll test and report back, thanks for the responses though!
d
yes, thats exactly it, use the
--create-only
flag and customise it
💯 1
t
The example is for renaming only, do you know whether I can keep the
VARCHAR(30)[]
at the end or is there a different syntax?
Copy code
RENAME COLUMN "tag" TO "tags" VARCHAR(30)[];
Tried this:
Copy code
ALTER TABLE "Post"
RENAME COLUMN "tag" TO "tags"
ALTER COLUMN "tags" VARCHAR(30)[];
But getting
Error querying the database: db error: ERROR: syntax error at or near "ALTER"