init
This commit is contained in:
9
alice/__init__.py
Normal file
9
alice/__init__.py
Normal file
@@ -0,0 +1,9 @@
|
||||
__version__ = '0.1.0'
|
||||
|
||||
|
||||
def main():
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
36
alice/backends/__init__.py
Normal file
36
alice/backends/__init__.py
Normal file
@@ -0,0 +1,36 @@
|
||||
from typing import Type
|
||||
|
||||
from tortoise import Model, BaseDBAsyncClient
|
||||
from tortoise.backends.base.schema_generator import BaseSchemaGenerator
|
||||
|
||||
|
||||
class DDL:
|
||||
schema_generator_cls: Type[BaseSchemaGenerator] = BaseSchemaGenerator
|
||||
|
||||
def __init__(self, client: "BaseDBAsyncClient", model: "Type[Model]"):
|
||||
self.model = model
|
||||
self.schema_generator = self.schema_generator_cls(client)
|
||||
|
||||
def create_table(self):
|
||||
return self.schema_generator._get_table_sql(self.model, True)['table_creation_string']
|
||||
|
||||
def drop_table(self):
|
||||
return f'drop table {self.model._meta.db_table}'
|
||||
|
||||
def add_column(self):
|
||||
raise NotImplementedError()
|
||||
|
||||
def drop_column(self):
|
||||
raise NotImplementedError()
|
||||
|
||||
def add_index(self):
|
||||
raise NotImplementedError()
|
||||
|
||||
def drop_index(self):
|
||||
raise NotImplementedError()
|
||||
|
||||
def add_fk(self):
|
||||
raise NotImplementedError()
|
||||
|
||||
def drop_fk(self):
|
||||
raise NotImplementedError()
|
||||
28
alice/backends/mysql/__init__.py
Normal file
28
alice/backends/mysql/__init__.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from tortoise.backends.mysql.schema_generator import MySQLSchemaGenerator
|
||||
|
||||
from alice.backends import DDL
|
||||
|
||||
|
||||
class MysqlDDL(DDL):
|
||||
schema_generator_cls = MySQLSchemaGenerator
|
||||
|
||||
def drop_table(self):
|
||||
pass
|
||||
|
||||
def add_column(self):
|
||||
pass
|
||||
|
||||
def drop_column(self):
|
||||
pass
|
||||
|
||||
def add_index(self):
|
||||
pass
|
||||
|
||||
def drop_index(self):
|
||||
pass
|
||||
|
||||
def add_fk(self):
|
||||
pass
|
||||
|
||||
def drop_fk(self):
|
||||
pass
|
||||
18
alice/cmd.py
Normal file
18
alice/cmd.py
Normal file
@@ -0,0 +1,18 @@
|
||||
class CommandLine:
|
||||
def __init__(self, argv):
|
||||
self.argv = argv
|
||||
|
||||
def migrate(self):
|
||||
pass
|
||||
|
||||
def upgrade(self):
|
||||
pass
|
||||
|
||||
def downgrade(self):
|
||||
pass
|
||||
|
||||
def init_db(self):
|
||||
pass
|
||||
|
||||
def init(self):
|
||||
pass
|
||||
0
alice/diff.py
Normal file
0
alice/diff.py
Normal file
Reference in New Issue
Block a user