class User(Model):
id = fields.BigIntField(pk=True)
class Client(Model):
id = fields.BigIntField(pk=True)
user = fields.ForeignKeyField("models.User", on_delete=fields.OnDelete.NO_ACTION, unique=True)
For this models aerich generate:
CREATE TABLE IF NOT EXISTS "users" (
"id" BIGSERIAL NOT NULL PRIMARY KEY
);
CREATE TABLE IF NOT EXISTS "clients" (
"id" BIGSERIAL NOT NULL PRIMARY KEY,
"user_id" BIGINT NOT NULL REFERENCES "users" ("id") ON DELETE NO ACTION
);
CREATE TABLE IF NOT EXISTS "aerich" (
"id" SERIAL NOT NULL PRIMARY KEY,
"version" VARCHAR(255) NOT NULL,
"app" VARCHAR(100) NOT NULL,
"content" JSONB NOT NULL
);
I am expecting unique constraint on the user_id column, but aerich is ignoring it
My models:
For this models aerich generate:
I am expecting unique constraint on the user_id column, but aerich is ignoring it