Closed julius425 closed 1 year ago
fixed
Juste tried 0.7.1rc1
and it seems it is still broken:
For the give model
class:
class Signature(DBObject):
label = fields.ForeignKeyField("models.Label", to_field="id",
related_name="label_signatures")
owner = fields.ForeignKeyField("models.Player", to_field="id",
related_name="player_signatures")
league = fields.ForeignKeyField('models.League',
related_name='league_signatures')
artist_id = fields.CharField(max_length=255)
advance = fields.IntField()
is_active = fields.BooleanField()
aerich
generates the following in 0.7.0
:
from typing import List
from tortoise import BaseDBAsyncClient
async def upgrade(db: BaseDBAsyncClient) -> List[str]:
return [
"""CREATE TABLE IF NOT EXISTS "signature" (
"id" UUID NOT NULL PRIMARY KEY,
"created_at" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
"artist_id" VARCHAR(255) NOT NULL,
"advance" INT NOT NULL,
"is_active" BOOL NOT NULL,
"label_id" UUID NOT NULL REFERENCES "label" ("id") ON DELETE CASCADE,
"league_id" UUID NOT NULL REFERENCES "league" ("id") ON DELETE CASCADE,
"owner_id" VARCHAR(50) NOT NULL REFERENCES "player" ("id") ON DELETE CASCADE
);"""
]
async def downgrade(db: BaseDBAsyncClient) -> List[str]:
return [
"""DROP TABLE IF EXISTS "signature""""
]
And the following in 0.7.1rc1
:
from typing import List
from tortoise import BaseDBAsyncClient
async def upgrade(db: BaseDBAsyncClient) -> List[str]:
return [
'CREATE TABLE IF NOT EXISTS "signature" (
"id" UUID NOT NULL PRIMARY KEY,
"created_at" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
"artist_id" VARCHAR(255) NOT NULL,
"advance" INT NOT NULL,
"is_active" BOOL NOT NULL,
"label_id" UUID NOT NULL REFERENCES "label" ("id") ON DELETE CASCADE,
"league_id" UUID NOT NULL REFERENCES "league" ("id") ON DELETE CASCADE,
"owner_id" VARCHAR(50) NOT NULL REFERENCES "player" ("id") ON DELETE CASCADE
);'
]
async def downgrade(db: BaseDBAsyncClient) -> List[str]:
return [
'DROP TABLE IF EXISTS "signature"'
]
And when I try to apply the migration I have the following error:
'CREATE TABLE IF NOT EXISTS "signature" (
^
SyntaxError: unterminated string literal (detected at line 8)
Try latest source again
aerich==0.7.0 tortoise-orm==0.17.6
my model:
aerich inits and creates field change migration normaly, but downgrade function seems invalid with stacking quotes:
and i get this while trying to upgrade: