From a3f459eecfec2beda2f51fb6d62eca4e5d5fbd70 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sat, 8 Jul 2006 17:13:21 +0000 Subject: Firebird migrations support. Closes #5337. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4594 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../fixtures/db_definitions/firebird3.drop.sql | 11 ----- .../test/fixtures/db_definitions/firebird3.sql | 49 ---------------------- .../test/fixtures/db_definitions/schema.rb | 12 +++++- 3 files changed, 11 insertions(+), 61 deletions(-) delete mode 100644 activerecord/test/fixtures/db_definitions/firebird3.drop.sql delete mode 100644 activerecord/test/fixtures/db_definitions/firebird3.sql (limited to 'activerecord/test/fixtures/db_definitions') diff --git a/activerecord/test/fixtures/db_definitions/firebird3.drop.sql b/activerecord/test/fixtures/db_definitions/firebird3.drop.sql deleted file mode 100644 index fc654212bd..0000000000 --- a/activerecord/test/fixtures/db_definitions/firebird3.drop.sql +++ /dev/null @@ -1,11 +0,0 @@ -DROP TABLE taggings; -DROP TABLE tags; -DROP TABLE categorizations; -DROP TABLE author_addresses; -DROP TABLE author_favorites; - -DROP GENERATOR taggings_seq; -DROP GENERATOR tags_seq; -DROP GENERATOR categorizations_seq; -DROP GENERATOR author_addresses_seq; -DROP GENERATOR author_favorites_seq; diff --git a/activerecord/test/fixtures/db_definitions/firebird3.sql b/activerecord/test/fixtures/db_definitions/firebird3.sql deleted file mode 100644 index 1d8e709d29..0000000000 --- a/activerecord/test/fixtures/db_definitions/firebird3.sql +++ /dev/null @@ -1,49 +0,0 @@ -CREATE TABLE taggings ( - id BIGINT NOT NULL, - tag_id BIGINT, - super_tag_id BIGINT, - taggable_type VARCHAR(255), - taggable_id BIGINT, - PRIMARY KEY (id) -); -CREATE GENERATOR taggings_seq; -SET GENERATOR taggings_seq TO 10000; - -CREATE TABLE tags ( - id BIGINT NOT NULL, - name VARCHAR(255), - taggings_count BIGINT DEFAULT 0, - PRIMARY KEY (id) -); -CREATE GENERATOR tags_seq; -SET GENERATOR tags_seq TO 10000; - -CREATE TABLE categorizations ( - id BIGINT NOT NULL, - category_id BIGINT, - post_id BIGINT, - author_id BIGINT, - PRIMARY KEY (id) -); -CREATE GENERATOR categorizations_seq; -SET GENERATOR categorizations_seq TO 10000; - -ALTER TABLE posts ADD taggings_count BIGINT DEFAULT 0; -ALTER TABLE authors ADD author_address_id BIGINT; - -CREATE TABLE author_addresses ( - id BIGINT NOT NULL, - author_address_id BIGINT, - PRIMARY KEY (id) -); -CREATE GENERATOR author_addresses_seq; -SET GENERATOR author_addresses_seq TO 10000; - -CREATE TABLE author_favorites ( - id BIGINT NOT NULL, - author_id BIGINT, - favorite_author_id BIGINT, - PRIMARY KEY (id) -); -CREATE GENERATOR author_favorites_seq; -SET GENERATOR author_favorites_seq TO 10000; diff --git a/activerecord/test/fixtures/db_definitions/schema.rb b/activerecord/test/fixtures/db_definitions/schema.rb index 7d10fbcadf..a5f2c9dc10 100644 --- a/activerecord/test/fixtures/db_definitions/schema.rb +++ b/activerecord/test/fixtures/db_definitions/schema.rb @@ -1,5 +1,15 @@ ActiveRecord::Schema.define do + # For Firebird, set the sequence values 10000 when create_table is called; + # this prevents primary key collisions between "normally" created records + # and fixture-based (YAML) records. + if adapter_name == "Firebird" + def create_table(*args, &block) + ActiveRecord::Base.connection.create_table(*args, &block) + ActiveRecord::Base.connection.execute "SET GENERATOR #{args.first}_seq TO 10000" + end + end + create_table :taggings, :force => true do |t| t.column :tag_id, :integer t.column :super_tag_id, :integer @@ -29,4 +39,4 @@ ActiveRecord::Schema.define do t.column :author_id, :integer t.column :favorite_author_id, :integer end -end \ No newline at end of file +end -- cgit v1.2.3