<commit_before>#
# Copyright (c) 2005-2008 rPath, Inc.
#

import os
import sys

from conary.conarycfg import loadEntitlement, EntitlementList
from conary.dbstore import migration, sqlerrors, sqllib, idtable
from conary.lib.tracelog import logMe
from mint import schema

# SCHEMA Migration
class SchemaMigration(migration.SchemaMigration):

    def __init__(self, db, cfg=None):
        migration.SchemaMigration.__init__(self, db)
        self.cfg = cfg

    def message(self, msg = None):
        if msg is None:
            msg = self.msg
        if msg == "":
            msg = "Finished migration to schema version %s" % (self.Version,)
        logMe(1, msg)
        self.msg = msg

# Helper functions
def add_columns(cu, table, *columns):
    '''
    Add each column while ignoring existing columns.

    >>> add_columns(cu, 'Table', 'something INTEGER',
    ...     'somethingelse STRING')
    '''

    for column in columns:
        try:
            cu.execute('ALTER TABLE %s ADD COLUMN %s' % (table, d))
        except sqlerrors.DuplicateColumnName:
            pass

def drop_tables(cu, *tables):
    '''
    Drop each table, ignoring any missing tables.<commit_msg>Fixed migrate add_columns breakage<commit_after>#
# Copyright (c) 2005-2008 rPath, Inc.
#

import os
import sys

from conary.conarycfg import loadEntitlement, EntitlementList
from conary.dbstore import migration, sqlerrors, sqllib, idtable
from conary.lib.tracelog import logMe
from mint import schema

# SCHEMA Migration
class SchemaMigration(migration.SchemaMigration):

    def __init__(self, db, cfg=None):
        migration.SchemaMigration.__init__(self, db)
        self.cfg = cfg

    def message(self, msg = None):
        if msg is None:
            msg = self.msg
        if msg == "":
            msg = "Finished migration to schema version %s" % (self.Version,)
        logMe(1, msg)
        self.msg = msg

# Helper functions
def add_columns(cu, table, *columns):
    '''
    Add each column while ignoring existing columns.

    >>> add_columns(cu, 'Table', 'something INTEGER',
    ...     'somethingelse STRING')
    '''

    for column in columns:
        try:
            cu.execute('ALTER TABLE %s ADD COLUMN %s' % (table, column))
        except sqlerrors.DuplicateColumnName:
            pass

def drop_tables(cu, *tables):
    '''
    Drop each table, ignoring any missing tables.
{'fraction_non_alphanumeric': 0.10092514718250631, 'fraction_numerical': 0.007569386038687973, 'mean_word_length': 2.776190476190476, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5851863', 'n_tokens_mistral': 725, 'n_tokens_neox': 703, 'n_words': 224}