Marvin
11/17/2020, 5:46 PMRyan
11/18/2020, 7:23 AMMarvin
11/18/2020, 9:58 AMRyan
11/18/2020, 9:59 AMprisma migrate --draft
2. Change the SQL accordingly
3. prisma migrate upMarvin
11/18/2020, 10:44 AMMarvin
11/20/2020, 5:22 PMCREATE TABLE with the new name and a DROP TABLE with the old name. But how can I know if they belong to the same model?
With only one change at a time, it's more or less clear because I can just search for the CREATE TABLE and DROP TABLE statements where I then can extract the names from and use them in a .ts file/script which manipulates the migration SQL draft file.
With multiple changes it's kinda tricky when there are more than one CREATE TABLE & DROP TABLE statements. Any idea how I could solve this? Is there maybe something I can use from the SDK or so?
As an example:
I create the schema dynamically with .ts files where I can provide a name in the function call (passed as argument). This function creates the model schema. Now when I change the name later, it should automatically migrate the data from the old table to the new one. So it needs to know the old name on execution which is obviously gone. :(Ryan
11/23/2020, 7:33 AM.ts files though, only .sql.Marvin
11/24/2020, 8:47 PMRyan
11/25/2020, 2:02 PMMarvin
11/25/2020, 7:42 PMCREATE TABLE & DROP TABLE statements in the generated SQL draft, extract the names from it and then create a ALTER TABLE statement from it which will be then inserted into the SQL draft. Later I can run the migrate command and it will be updated. That works good if you only have one CREATE TABLE and one DROP TABLE statement, but I think you can't be 100% sure these both statements are connected. Especially if you have more than one from each, you can't say which CREATE TABLE is connected to which DROP TABLE statement.Alberto Perdomo
Alberto Perdomo
Marvin
11/27/2020, 8:36 PM