当前位置: 首页>>代码示例>>Python>>正文


Python migrate.PostgresqlMigrator方法代码示例

本文整理汇总了Python中playhouse.migrate.PostgresqlMigrator方法的典型用法代码示例。如果您正苦于以下问题:Python migrate.PostgresqlMigrator方法的具体用法?Python migrate.PostgresqlMigrator怎么用?Python migrate.PostgresqlMigrator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在playhouse.migrate的用法示例。


在下文中一共展示了migrate.PostgresqlMigrator方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: init_postgres

# 需要导入模块: from playhouse import migrate [as 别名]
# 或者: from playhouse.migrate import PostgresqlMigrator [as 别名]
def init_postgres(url):
    global DB

    db_name = url.path.strip("/")

    DB.initialize(PostgresqlDatabase(
        database=db_name,
        user=url.user or None,
        password=url.password or None,
        host=url.host,
        autocommit=bool(url.get('autocommit', True)),
        autorollback=bool(url.get('autorollback', True))
    ))
    log.info("Database initialized as '%s'. Checking migrations...", db_name)
    return DB, PostgresqlMigrator(DB) 
开发者ID:mosquito,项目名称:pypi-server,代码行数:17,代码来源:__init__.py

示例2: migrate

# 需要导入模块: from playhouse import migrate [as 别名]
# 或者: from playhouse.migrate import PostgresqlMigrator [as 别名]
def migrate(migrations=MIGRATIONS):
    db = get_db()
    migrator = m.PostgresqlMigrator(db)
    for migration in migrations:
        migration(db, migrator) 
开发者ID:vilmibm,项目名称:tildemush,代码行数:7,代码来源:migrations.py

示例3: __init__

# 需要导入模块: from playhouse import migrate [as 别名]
# 或者: from playhouse.migrate import PostgresqlMigrator [as 别名]
def __init__(self, rules, func):
        self.rules = rules
        self.func = func
        self.actions = []
        self.raw_actions = []
        self.m = PostgresqlMigrator(database) 
开发者ID:b1naryth1ef,项目名称:rowboat,代码行数:8,代码来源:__init__.py

示例4: run_migrate

# 需要导入模块: from playhouse import migrate [as 别名]
# 或者: from playhouse.migrate import PostgresqlMigrator [as 别名]
def run_migrate(*args):
    '''
    running some migration.
    '''

    print('Begin migrate ...')

    torcms_migrator = migrate.PostgresqlMigrator(config.DB_CON)

    memo_field = migrate.TextField(null=False, default='', help_text='Memo', )
    try:
        migrate.migrate(torcms_migrator.add_column('tabpost', 'memo', memo_field))
    except:
        pass

    desc_field = migrate.CharField(null=False, default='', max_length=255, help_text='')
    try:
        migrate.migrate(torcms_migrator.add_column('tabentity', 'desc', desc_field))
    except:
        pass

    extinfo_field = BinaryJSONField(null=False, default={}, help_text='Extra data in JSON.')
    try:
        migrate.migrate(torcms_migrator.add_column('tabmember', 'extinfo', extinfo_field))
    except:
        pass

    par_id_field = migrate.CharField(null=False, default='', max_length=4,
                                     help_text='父类id,对于label,top_id为""')
    try:
        migrate.migrate(torcms_migrator.add_column('tabpost2tag', 'par_id', par_id_field))
    except:
        pass

    category_field = migrate.CharField(null=False, default='0', max_length=1,
                                       help_text='0为评论,1为回复')
    try:
        migrate.migrate(torcms_migrator.add_column('tabreply', 'category', category_field))
    except:
        pass

    try:
        migrate.migrate(torcms_migrator.drop_column('tabentity2user', 'count'))
        # print('删除字段成功:count.')
    except:
        pass

    user_ip_field = migrate.CharField(null=False, default='0', help_text='User IP Address', )
    try:
        migrate.migrate(torcms_migrator.add_column('tabentity2user', 'user_ip', user_ip_field))
        # print('添加字段成功:user_ip.')
    except:
        pass

    print('Migration finished.') 
开发者ID:bukun,项目名称:TorCMS,代码行数:57,代码来源:script_migrate.py


注:本文中的playhouse.migrate.PostgresqlMigrator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。