Commit 6e025c4a authored by iElectric's avatar iElectric

add firebird to test_db.cfg.tmpl; fix bug when dropping a column in firebird:...

add firebird to test_db.cfg.tmpl; fix bug when dropping a column in firebird: also drop related constraint or index
parent ec75b93b
......@@ -23,3 +23,4 @@ make_update_script_for_model:
- managing output - logging
- required_dbs tests
- add story to changeset tutorial
- verbose output on migration failures
......@@ -18,6 +18,19 @@ class FBColumnDropper(ansisql.ANSIColumnDropper):
"""Firebird column dropper implementation."""
def visit_column(self, column):
"""Firebird supports 'DROP col' instead of 'DROP COLUMN col' syntax
Drop primary key and unique constraints if dropped column is referencing it."""
if column.primary_key:
if column.table.primary_key.columns.contains_column(column):
column.table.primary_key.drop()
# TODO: recreate primary key if it references more than this column
if column.unique or getattr(column, 'unique_name', None):
for cons in column.table.constraints:
if cons.contains_column(column):
cons.drop()
# TODO: recreate unique constraint if it refenrences more than this column
table = self.start_alter_table(column)
self.append('DROP %s' % self.preparer.format_column(column))
self.execute()
......
......@@ -6,3 +6,4 @@ pytz
psycopg2
pysqlite
mysql-python
http://sourceforge.net/projects/kinterbasdb/files/kinterbasdb/kinterbasdb-3.2/kinterbasdb-3.2.src.tar.gz/download
......@@ -11,4 +11,4 @@ sqlite:///__tmp__
postgresql://scott:tiger@localhost/test_migrate
mysql://scott:tiger@localhost/test_migrate
oracle://scott:tiger@localhost
# TODO: add firebird
firebird://scott:tiger@localhost//var/lib/firebird/databases/test_migrate
......@@ -204,7 +204,7 @@ class TestAddDropColumn(fixture.DB):
self.fail()
col.drop()
@fixture.usedb(not_supported='mysql')
def test_check(self):
"""Can create columns with check constraint"""
......@@ -245,6 +245,7 @@ class TestAddDropColumn(fixture.DB):
col.drop(self.table)
# TODO: remove already attached columns with indexes, uniques, pks, fks ..
@fixture.usedb()
def test_index(self):
"""Can create columns with indexes"""
......@@ -469,19 +470,13 @@ class TestColumnChange(fixture.DB):
self.table.c.data.alter(Column('data', String(42)))
self.refresh_table(self.table.name)
self.assert_(isinstance(self.table.c.data.type, String))
if self.engine.name == 'firebird':
self.assertEquals(self.table.c.data.type.length, 42 * 4)
else:
self.assertEquals(self.table.c.data.type.length, 42)
self.assertEquals(self.table.c.data.type.length, 42)
# Just the new type
self.table.c.data.alter(type=String(43))
self.refresh_table(self.table.name)
self.assert_(isinstance(self.table.c.data.type, String))
if self.engine.name == 'firebird':
self.assertEquals(self.table.c.data.type.length, 43 * 4)
else:
self.assertEquals(self.table.c.data.type.length, 43)
self.assertEquals(self.table.c.data.type.length, 43)
# Different type
self.assert_(isinstance(self.table.c.id.type, Integer))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment