Migration commit from heyvince.co to heyvince.ca
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import click
|
||||
from ..base import files, sources
|
||||
from ..base.config import config as cfg
|
||||
from ..base import migrator as mig
|
||||
from alembic.config import Config
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.option('-m', default="", help='Description of your migration')
|
||||
def createmigration(m):
|
||||
#TODO: Validate init is done
|
||||
click.echo("Generating migration files... but first lets remove your models")
|
||||
|
||||
# Delete files from model folder
|
||||
files.delete_file(cfg["migration-path"]+"/models", donot=["base.py"])
|
||||
|
||||
# Iterate over query-paths
|
||||
query_paths = files.get_filepaths(cfg["query-paths"])
|
||||
for filepath in query_paths:
|
||||
conf, query = files.process_query_file(filepath)
|
||||
src = sources.get_source(conf["extract_from"],filepath)
|
||||
src.generate_model(query)
|
||||
|
||||
# Generate Init file
|
||||
files.generate_init(query_paths)
|
||||
mig.create_migration_file(script_message=str(m))
|
||||
click.echo("Creation migration is done !")
|
||||
|
||||
|
||||
@click.command()
|
||||
def migrate():
|
||||
mig.migrate()
|
||||
Reference in New Issue
Block a user