當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。