aerich
aerich copied to clipboard
Migrations Not Ordered Post init-db command !
Description: activity1 table already existed at init-db stage ! activity2 was created later during development and activity1 table was added a foreign relation to activity2 table. Below the generated migration using the below command
aerich migrate --name migration_name
A solution to this will give a lot of respite to tortoise orm users who are used to django migrations
CREATE TABLE IF NOT EXISTS "activity1" (
"id" UUID NOT NULL PRIMARY KEY,
"created_at" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
"created_by" VARCHAR(50) DEFAULT '',
"updated_by" VARCHAR(50) DEFAULT '',
"is_active" BOOL NOT NULL DEFAULT True,
"activity_data" JSONB NOT NULL,
"description" VARCHAR(64),
"schematic_id" UUID REFERENCES "schema_definitions" ("id") ON DELETE RESTRICT,
"lead_id" UUID NOT NULL REFERENCES "lead" ("id") ON DELETE RESTRICT,
"activity2_id" UUID REFERENCES "activity2" ("id") ON DELETE RESTRICT
);
CREATE TABLE IF NOT EXISTS "activity2" (
"id" UUID NOT NULL PRIMARY KEY,
"created_at" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
"created_by" VARCHAR(50) DEFAULT '',
"updated_by" VARCHAR(50) DEFAULT '',
"is_active" BOOL NOT NULL DEFAULT True,
"activity_data" JSONB NOT NULL,
"description" VARCHAR(64),
"schematic_id" UUID REFERENCES "schema_definitions" ("id") ON DELETE RESTRICT,
"lead_id" UUID NOT NULL REFERENCES "lead" ("id") ON DELETE RESTRICT
);
@long2ice also I would suggest to get rid of mentioning the name of the migration especially in multi member environment!