I think we need more tools for fixing broken migrations!

When I have something broken, sometimes I go into the sql console,
edit the database manually, and then use these functions to tell
web2py that I've changed the table in sql.  (However, I haven't had to
use these for at least a year... maybe some dal bugs have been fixed
and migrations don't break as frequently anymore?)

def db_hash():
    import cPickle, hashlib
    return hashlib.md5(database).hexdigest()

def get_migrate_status(table_name):
    import cPickle, hashlib
    f = open('applications/init/databases/%s_%s.table'
             % (hashlib.md5(database).hexdigest(),
                table_name),
             'r')
    result = cPickle.load(f)
    f.close()
    return result

def save_migrate_status(table_name, status):
    import cPickle, hashlib
    f = open('applications/init/databases/%s_%s.table'
             % (hashlib.md5(database).hexdigest(),
                table_name),
             'w')
    cPickle.dump(status, f)
    f.close()
    print 'saved'

def del_migrate_column(table_name, column_name):
    a = get_migrate_status(table_name)
    del a[column_name]
    save_migrate_status(table_name, a)


On Sep 9, 11:17 am, pbreit <pbreitenb...@gmail.com> wrote:
> I think we need some more documentation on migrations, especially around
> fixing broken migrations, how to modify schema manually, how the sql.log and
> .table files work and how/when to recreate, etc.

Reply via email to