From 4adf7f1b401955a1938cfc7a9decdc77af2fab20 Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" <> Date: Sat, 24 Oct 2009 05:30:14 +0000 Subject: Bug 519584: Implement a framework for migrating from other bug-trackers, and start with a GNATS importer. Patch by Max Kanat-Alexander (module owner) a=mkanat --- Bugzilla/DB/Schema/Mysql.pm | 5 +++++ Bugzilla/DB/Schema/Oracle.pm | 9 +++++++++ Bugzilla/DB/Schema/Pg.pm | 6 ++++++ 3 files changed, 20 insertions(+) (limited to 'Bugzilla/DB/Schema') diff --git a/Bugzilla/DB/Schema/Mysql.pm b/Bugzilla/DB/Schema/Mysql.pm index 95ef3141e..a68c7c90d 100644 --- a/Bugzilla/DB/Schema/Mysql.pm +++ b/Bugzilla/DB/Schema/Mysql.pm @@ -263,6 +263,11 @@ sub get_rename_indexes_ddl { return ($sql); } +sub get_set_serial_sql { + my ($self, $table, $column, $value) = @_; + return ("ALTER TABLE $table AUTO_INCREMENT = $value"); +} + # Converts a DBI column_info output to an abstract column definition. # Expects to only be called by Bugzila::DB::Mysql::_bz_build_schema_from_disk, # although there's a chance that it will also work properly if called diff --git a/Bugzilla/DB/Schema/Oracle.pm b/Bugzilla/DB/Schema/Oracle.pm index 615987b06..814a842b3 100644 --- a/Bugzilla/DB/Schema/Oracle.pm +++ b/Bugzilla/DB/Schema/Oracle.pm @@ -403,4 +403,13 @@ sub _get_create_seq_ddl { return @ddl; } +sub get_set_serial_sql { + my ($self, $table, $column, $value) = @_; + my @sql; + my $seq_name = "${table}_${column}_SEQ"; + push(@sql, "DROP SEQUENCE ${seq_name}"); + push(@sql, $self->_get_create_seq_ddl($table, $column, $value)); + return @sql; +} + 1; diff --git a/Bugzilla/DB/Schema/Pg.pm b/Bugzilla/DB/Schema/Pg.pm index 070c0b03e..3559bae9c 100644 --- a/Bugzilla/DB/Schema/Pg.pm +++ b/Bugzilla/DB/Schema/Pg.pm @@ -119,6 +119,12 @@ sub get_rename_table_sql { return ("ALTER TABLE $old_name RENAME TO $new_name"); } +sub get_set_serial_sql { + my ($self, $table, $column, $value) = @_; + return ("SELECT setval('${table}_${column}_seq', $value, false) + FROM $table"); +} + sub _get_alter_type_sql { my ($self, $table, $column, $new_def, $old_def) = @_; my @statements; -- cgit v1.2.3-24-g4f1b