I like sqlite, but right now I’m stuck with a problem to add a column if not exists to a table with a migration script. Couldn’t find a working solutions . Can somebody help?
I like sqlite, but right now I’m stuck with a problem to add a column if not exists to a table with a migration script. Couldn’t find a working solutions . Can somebody help?
ALTER TABLE TableName ADD ColumnName INT
You'll have to check whether it exists first, I don't know how to do that in SQLite, I assume it has to do with information_Schema
That’s the problem. I try to run a migration. i want to copy data from column a to column b. Column b is not present in new version. So inorder to make the script not fail, I’ve to make sure column b is present. One way is to add it if not exists. I’m checking something like alter table add column if not exists syntax in postgres
6
u/Individual_Ad583 Apr 29 '23
I like sqlite, but right now I’m stuck with a problem to add a column if not exists to a table with a migration script. Couldn’t find a working solutions . Can somebody help?