~russell/ibid/jira-plugin

« back to all changes in this revision

Viewing changes to ibid/models.py

  • Committer: Stefano Rivera
  • Date: 2009-10-16 16:31:34 UTC
  • Revision ID: stefano@rivera.za.net-20091016163134-d6rj65szlrl9afmb
Strip trailing white-space

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
    When you have upgrades to the schema, instead of using VersionedSchema
27
27
    directly, derive from it and include your own upgrade_x_to_y(self) methods,
28
28
    where y = x + 1
29
 
    
 
29
 
30
30
    In the upgrade methods, you can call the helper functions:
31
31
    add_column, drop_column, rename_column, alter_column
32
32
    They try to do the correct thing in most situations, including rebuilding
300
300
                            ]
301
301
                            recreate.append((isinstance(constraint, UniqueConstraint),
302
302
                                self._mysql_constraint_createstring(constraint)))
303
 
            
 
303
 
304
304
            session.execute('ALTER TABLE "%s" CHANGE "%s" %s;' %
305
305
                (table.name, old_col.name, description))
306
306
 
316
316
                (table.name, col.name, description.split(" ", 3)[1]))
317
317
 
318
318
            if old_col.nullable != col.nullable:
319
 
                session.execute('ALTER TABLE "%s" ALTER COLUMN "%s" %s NOT NULL;' % 
 
319
                session.execute('ALTER TABLE "%s" ALTER COLUMN "%s" %s NOT NULL;' %
320
320
                    (table.name, col.name, col.nullable and 'DROP' or 'SET'))
321
321
 
322
322
    def _rebuild_sqlite(self, colmap):
378
378
            self.add_index(self.table.c.table, unique=True)
379
379
 
380
380
    __table__.versioned_schema = SchemaSchema(__table__, 2)
381
 
    
 
381
 
382
382
    def __init__(self, table, version=0):
383
383
        self.table = table
384
384
        self.version = version