diff options
Diffstat (limited to 'spec/support/schemas')
-rw-r--r-- | spec/support/schemas/mysql_schema.rb | 26 | ||||
-rw-r--r-- | spec/support/schemas/oracle_schema.rb | 20 | ||||
-rw-r--r-- | spec/support/schemas/postgresql_schema.rb | 26 | ||||
-rw-r--r-- | spec/support/schemas/sqlite3_schema.rb | 26 |
4 files changed, 98 insertions, 0 deletions
diff --git a/spec/support/schemas/mysql_schema.rb b/spec/support/schemas/mysql_schema.rb new file mode 100644 index 0000000000..a2e913d756 --- /dev/null +++ b/spec/support/schemas/mysql_schema.rb @@ -0,0 +1,26 @@ +sql = <<-SQL + DROP TABLE IF EXISTS users; + CREATE TABLE users ( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(255) NOT NULL + ); + + DROP TABLE IF EXISTS photos; + CREATE TABLE photos ( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + user_id INTEGER NOT NULL, + camera_id INTEGER NOT NULL + ); + DROP TABLE IF EXISTS developers; + CREATE TABLE developers ( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(255) NOT NULL, + salary INTEGER NOT NULL, + department VARCHAR(255) NOT NULL, + created_at TIMESTAMP NOT NULL + ); +SQL + +sql.split(/;/).select(&:present?).each do |sql_statement| + ActiveRecord::Base.connection.execute sql_statement +end diff --git a/spec/support/schemas/oracle_schema.rb b/spec/support/schemas/oracle_schema.rb new file mode 100644 index 0000000000..c8207c8d98 --- /dev/null +++ b/spec/support/schemas/oracle_schema.rb @@ -0,0 +1,20 @@ +ActiveRecord::Schema.define do + suppress_messages do + create_table :users, :primary_key_trigger => true, :force => true do |t| + t.string :name, :limit => 255, :null => false + end + + create_table :photos, :primary_key_trigger => true, :force => true do |t| + t.integer :user_id + t.integer :camera_id + end + + create_table :developers, :primary_key_trigger => true, :force => true do |t| + t.string :name, :limit => 255, :null => false + t.integer :salary + t.string :department, :limit => 255, :null => false + t.timestamp :created_at, :null => false + end + + end +end diff --git a/spec/support/schemas/postgresql_schema.rb b/spec/support/schemas/postgresql_schema.rb new file mode 100644 index 0000000000..23a48f5ad8 --- /dev/null +++ b/spec/support/schemas/postgresql_schema.rb @@ -0,0 +1,26 @@ +sql = <<-SQL + DROP TABLE IF EXISTS users; + CREATE TABLE users ( + id SERIAL PRIMARY KEY NOT NULL, + name VARCHAR(255) NOT NULL + ); + + DROP TABLE IF EXISTS photos; + CREATE TABLE photos ( + id SERIAL PRIMARY KEY NOT NULL, + user_id INTEGER NOT NULL, + camera_id INTEGER NOT NULL + ); + DROP TABLE IF EXISTS developers; + CREATE TABLE developers ( + id SERIAL PRIMARY KEY NOT NULL, + name VARCHAR(255) NOT NULL, + salary INTEGER NOT NULL, + department VARCHAR(255) NOT NULL, + created_at TIMESTAMP NOT NULL + ); +SQL + +sql.split(/;/).select(&:present?).each do |sql_statement| + ActiveRecord::Base.connection.execute sql_statement +end diff --git a/spec/support/schemas/sqlite3_schema.rb b/spec/support/schemas/sqlite3_schema.rb new file mode 100644 index 0000000000..c1fed70859 --- /dev/null +++ b/spec/support/schemas/sqlite3_schema.rb @@ -0,0 +1,26 @@ +sql = <<-SQL + DROP TABLE IF EXISTS users; + CREATE TABLE users ( + id INTEGER NOT NULL PRIMARY KEY, + name VARCHAR(255) NOT NULL + ); + + DROP TABLE IF EXISTS photos; + CREATE TABLE photos ( + id INTEGER NOT NULL PRIMARY KEY, + user_id INTEGER NOT NULL, + camera_id INTEGER NOT NULL + ); + DROP TABLE IF EXISTS developers; + CREATE TABLE developers ( + id INTEGER NOT NULL PRIMARY KEY, + name VARCHAR(255) NOT NULL, + salary INTEGER NOT NULL, + department VARCHAR(255) NOT NULL, + created_at TIMESTAMP NOT NULL + ); +SQL + +sql.split(/;/).select(&:present?).each do |sql_statement| + ActiveRecord::Base.connection.execute sql_statement +end |