[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: cli.py
File is not writable. Editing disabled.
""" CLI integration. """ import os import re import sys import click from playhouse.db_url import connect from peewee_migrate.compat import string_types VERBOSE = ['WARNING', 'INFO', 'DEBUG', 'NOTSET'] CLEAN_RE = re.compile(r'\s+$', re.M) def get_router(directory, database, verbose=0): from peewee_migrate import LOGGER from peewee_migrate.compat import exec_in from peewee_migrate.router import Router logging_level = VERBOSE[verbose] config = {} try: with open(os.path.join(directory, 'conf.py')) as cfg: exec_in(cfg.read(), config, config) database = config.get('DATABASE', database) logging_level = config.get('LOGGING_LEVEL', logging_level).upper() except IOError: pass if isinstance(database, string_types): database = connect(database) LOGGER.setLevel(logging_level) try: return Router(database, migrate_dir=directory) except RuntimeError as exc: LOGGER.error(exc) return sys.exit(1) @click.group() def cli(): pass @cli.command() @click.option('--name', default=None, help="Select migration") @click.option('--database', default=None, help="Database connection") @click.option('--directory', default='migrations', help="Directory where migrations are stored") @click.option('--fake', default=False, help=("Run migration as fake.")) @click.option('-v', '--verbose', count=True) def migrate(name=None, database=None, directory=None, verbose=None, fake=False): """ Run migrations. """ router = get_router(directory, database, verbose) migrations = router.run(name, fake=fake) if migrations: click.echo('Migrations completed: %s' % ', '.join(migrations)) @cli.command() @click.argument('name') @click.option('--auto', default=False, help=( "Create migrations automatically. Set path to your models module.")) @click.option('--database', default=None, help="Database connection") @click.option('--directory', default='migrations', help="Directory where migrations are stored") @click.option('-v', '--verbose', count=True) def create(name, database=None, auto=False, directory=None, verbose=None): """ Create migration. """ router = get_router(directory, database, verbose) router.create(name, auto=auto) @cli.command() @click.argument('name') @click.option('--database', default=None, help="Database connection") @click.option('--directory', default='migrations', help="Directory where migrations are stored") @click.option('-v', '--verbose', count=True) def rollback(name, database=None, directory=None, verbose=None): """ Rollback migration.""" router = get_router(directory, database, verbose) router.rollback(name)
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server05.hostinghome.co.in
Server IP: 192.168.74.40
PHP Version: 7.4.33
Server Software: Apache
System: Linux server05.hostinghome.co.in 3.10.0-962.3.2.lve1.5.81.el7.x86_64 #1 SMP Wed May 31 10:36:47 UTC 2023 x86_64
HDD Total: 1.95 TB
HDD Free: 691.13 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Disabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: itsweb
User ID (UID): 1619
Group ID (GID): 1621
Script Owner UID: 1619
Current Dir Owner: N/A