Commit f5516214 authored by Roman Desyatskii's avatar Roman Desyatskii

Migrations

parent e32f42c0
from tortoise import BaseDBAsyncClient
async def upgrade(db: BaseDBAsyncClient) -> str:
return """
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
);
CREATE TABLE IF NOT EXISTS "article" (
"id" SERIAL NOT NULL PRIMARY KEY,
"name" TEXT NOT NULL
);"""
async def downgrade(db: BaseDBAsyncClient) -> str:
return """
"""
from tortoise import BaseDBAsyncClient
async def upgrade(db: BaseDBAsyncClient) -> str:
return """
CREATE TABLE IF NOT EXISTS "person" (
"id" SERIAL NOT NULL PRIMARY KEY,
"name" VARCHAR(255),
"birth_date" DATE
);
CREATE TABLE IF NOT EXISTS "genre" (
"id" SERIAL NOT NULL PRIMARY KEY,
"name" VARCHAR(255) NOT NULL UNIQUE,
"description" TEXT
);"""
async def downgrade(db: BaseDBAsyncClient) -> str:
return """
DROP TABLE IF EXISTS "person";
DROP TABLE IF EXISTS "genre";"""
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment