mirror of
https://github.com/planetmint/planetmint.git
synced 2025-06-11 08:36:38 +00:00
added migration commands
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
parent
47e7eeb4fe
commit
052979b5d9
@ -137,6 +137,30 @@ def init_database(connection, dbname):
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
@singledispatch
|
||||
def migrate_up(connection):
|
||||
"""Migrate database up
|
||||
|
||||
Args:
|
||||
connection (:class:`~planetmint.backend.connection.Connection`): an
|
||||
existing connection to use to migrate the database.
|
||||
Creates one if not given.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
@singledispatch
|
||||
def migrate_down(connection):
|
||||
"""Migrate database down
|
||||
|
||||
Args:
|
||||
connection (:class:`~planetmint.backend.connection.Connection`): an
|
||||
existing connection to use to migrate the database.
|
||||
Creates one if not given.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
def validate_language_key(obj, key):
|
||||
"""Validate all nested "language" key in `obj`.
|
||||
|
||||
|
@ -35,3 +35,13 @@ def create_database(connection, dbname):
|
||||
@register_schema(TarantoolDBConnection)
|
||||
def create_tables(connection, dbname):
|
||||
connection.connect().call("init")
|
||||
|
||||
|
||||
@register_schema(TarantoolDBConnection)
|
||||
def migrate_up(connection):
|
||||
connection.connect().call("migrate_up")
|
||||
|
||||
|
||||
@register_schema(TarantoolDBConnection)
|
||||
def migrate_down(connection):
|
||||
connection.connect().call("migrate_down")
|
||||
|
@ -258,6 +258,16 @@ def run_init(args):
|
||||
_run_init()
|
||||
|
||||
|
||||
@configure_planetmint
|
||||
def run_migrate_up(args):
|
||||
return
|
||||
|
||||
|
||||
@configure_planetmint
|
||||
def run_migrate_down(args):
|
||||
return
|
||||
|
||||
|
||||
@configure_planetmint
|
||||
def run_drop(args):
|
||||
"""Drop the database"""
|
||||
@ -363,6 +373,10 @@ def create_parser():
|
||||
|
||||
subparsers.add_parser("drop", help="Drop the database")
|
||||
|
||||
subparsers.add_parser("migrate_up", help="Migrate up")
|
||||
|
||||
subparsers.add_parser("migrate_down", help="Migrate down")
|
||||
|
||||
# parser for starting Planetmint
|
||||
start_parser = subparsers.add_parser("start", help="Start Planetmint")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user