From 105a27f39ee9dbfd7fdb2b25e5ba38b00708b66c Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Fri, 18 Jan 2008 07:29:00 +0000 Subject: move schema git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8659 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/test/schema/db2.drop.sql | 33 +++ activerecord/test/schema/db2.sql | 235 +++++++++++++++++ activerecord/test/schema/db22.drop.sql | 1 + activerecord/test/schema/db22.sql | 4 + activerecord/test/schema/firebird.drop.sql | 65 +++++ activerecord/test/schema/firebird.sql | 310 ++++++++++++++++++++++ activerecord/test/schema/firebird2.drop.sql | 2 + activerecord/test/schema/firebird2.sql | 6 + activerecord/test/schema/frontbase.drop.sql | 33 +++ activerecord/test/schema/frontbase.sql | 273 ++++++++++++++++++++ activerecord/test/schema/frontbase2.drop.sql | 1 + activerecord/test/schema/frontbase2.sql | 4 + activerecord/test/schema/openbase.drop.sql | 2 + activerecord/test/schema/openbase.sql | 318 +++++++++++++++++++++++ activerecord/test/schema/openbase2.drop.sql | 2 + activerecord/test/schema/openbase2.sql | 7 + activerecord/test/schema/oracle.drop.sql | 67 +++++ activerecord/test/schema/oracle.sql | 330 ++++++++++++++++++++++++ activerecord/test/schema/oracle2.drop.sql | 2 + activerecord/test/schema/oracle2.sql | 6 + activerecord/test/schema/postgresql.drop.sql | 44 ++++ activerecord/test/schema/postgresql.sql | 292 +++++++++++++++++++++ activerecord/test/schema/postgresql2.drop.sql | 1 + activerecord/test/schema/postgresql2.sql | 4 + activerecord/test/schema/schema.rb | 358 ++++++++++++++++++++++++++ activerecord/test/schema/schema2.rb | 11 + activerecord/test/schema/sqlite.drop.sql | 33 +++ activerecord/test/schema/sqlite.sql | 219 ++++++++++++++++ activerecord/test/schema/sqlite2.drop.sql | 1 + activerecord/test/schema/sqlite2.sql | 4 + activerecord/test/schema/sybase.drop.sql | 35 +++ activerecord/test/schema/sybase.sql | 222 ++++++++++++++++ activerecord/test/schema/sybase2.drop.sql | 2 + activerecord/test/schema/sybase2.sql | 5 + 34 files changed, 2932 insertions(+) create mode 100644 activerecord/test/schema/db2.drop.sql create mode 100644 activerecord/test/schema/db2.sql create mode 100644 activerecord/test/schema/db22.drop.sql create mode 100644 activerecord/test/schema/db22.sql create mode 100644 activerecord/test/schema/firebird.drop.sql create mode 100644 activerecord/test/schema/firebird.sql create mode 100644 activerecord/test/schema/firebird2.drop.sql create mode 100644 activerecord/test/schema/firebird2.sql create mode 100644 activerecord/test/schema/frontbase.drop.sql create mode 100644 activerecord/test/schema/frontbase.sql create mode 100644 activerecord/test/schema/frontbase2.drop.sql create mode 100644 activerecord/test/schema/frontbase2.sql create mode 100644 activerecord/test/schema/openbase.drop.sql create mode 100644 activerecord/test/schema/openbase.sql create mode 100644 activerecord/test/schema/openbase2.drop.sql create mode 100644 activerecord/test/schema/openbase2.sql create mode 100644 activerecord/test/schema/oracle.drop.sql create mode 100644 activerecord/test/schema/oracle.sql create mode 100644 activerecord/test/schema/oracle2.drop.sql create mode 100644 activerecord/test/schema/oracle2.sql create mode 100644 activerecord/test/schema/postgresql.drop.sql create mode 100644 activerecord/test/schema/postgresql.sql create mode 100644 activerecord/test/schema/postgresql2.drop.sql create mode 100644 activerecord/test/schema/postgresql2.sql create mode 100644 activerecord/test/schema/schema.rb create mode 100644 activerecord/test/schema/schema2.rb create mode 100644 activerecord/test/schema/sqlite.drop.sql create mode 100644 activerecord/test/schema/sqlite.sql create mode 100644 activerecord/test/schema/sqlite2.drop.sql create mode 100644 activerecord/test/schema/sqlite2.sql create mode 100644 activerecord/test/schema/sybase.drop.sql create mode 100644 activerecord/test/schema/sybase.sql create mode 100644 activerecord/test/schema/sybase2.drop.sql create mode 100644 activerecord/test/schema/sybase2.sql (limited to 'activerecord/test/schema') diff --git a/activerecord/test/schema/db2.drop.sql b/activerecord/test/schema/db2.drop.sql new file mode 100644 index 0000000000..286066ea20 --- /dev/null +++ b/activerecord/test/schema/db2.drop.sql @@ -0,0 +1,33 @@ +DROP TABLE accounts; +DROP TABLE funny_jokes; +DROP TABLE companies; +DROP TABLE topics; +DROP TABLE developers; +DROP TABLE projects; +DROP TABLE developers_projects; +DROP TABLE orders; +DROP TABLE customers; +DROP TABLE movies; +DROP TABLE subscribers; +DROP TABLE booleantests; +DROP TABLE auto_id_tests; +DROP TABLE entrants; +DROP TABLE colnametests; +DROP TABLE mixins; +DROP TABLE people; +DROP TABLE readers; +DROP TABLE binaries; +DROP TABLE computers; +DROP TABLE posts; +DROP TABLE comments; +DROP TABLE authors; +DROP TABLE tasks; +DROP TABLE categories; +DROP TABLE categories_posts; +DROP TABLE fk_test_has_pk; +DROP TABLE fk_test_has_fk; +DROP TABLE keyboards; +DROP TABLE legacy_things; +DROP TABLE numeric_data; +DROP TABLE mixed_case_monkeys; +DROP TABLE minimalistics; diff --git a/activerecord/test/schema/db2.sql b/activerecord/test/schema/db2.sql new file mode 100644 index 0000000000..6e088bd8ed --- /dev/null +++ b/activerecord/test/schema/db2.sql @@ -0,0 +1,235 @@ +CREATE TABLE accounts ( + id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000), + firm_id INT DEFAULT NULL, + credit_limit INT DEFAULT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE funny_jokes ( + id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000), + name VARCHAR(50) DEFAULT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE companies ( + id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000), + type VARCHAR(50) DEFAULT NULL, + ruby_type VARCHAR(50) DEFAULT NULL, + firm_id INT DEFAULT NULL, + name VARCHAR(50) DEFAULT NULL, + client_of INT DEFAULT NULL, + rating INT DEFAULT 1, + PRIMARY KEY (id) +); + +CREATE TABLE topics ( + id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000), + title VARCHAR(255) DEFAULT NULL, + author_name VARCHAR(255) DEFAULT NULL, + author_email_address VARCHAR(255) DEFAULT NULL, + written_on TIMESTAMP DEFAULT NULL, + bonus_time TIME DEFAULT NULL, + last_read DATE DEFAULT NULL, + content VARCHAR(3000), + approved SMALLINT DEFAULT 1, + replies_count INT DEFAULT 0, + parent_id INT DEFAULT NULL, + type VARCHAR(50) DEFAULT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE developers ( + id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000), + name VARCHAR(100) DEFAULT NULL, + salary INT DEFAULT 70000, + created_at TIMESTAMP DEFAULT NULL, + updated_at TIMESTAMP DEFAULT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE projects ( + id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000), + name VARCHAR(100) DEFAULT NULL, + type VARCHAR(255) DEFAULT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE developers_projects ( + developer_id INT NOT NULL, + project_id INT NOT NULL, + joined_on DATE DEFAULT NULL, + access_level SMALLINT DEFAULT 1 +); + +CREATE TABLE orders ( + id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000), + name VARCHAR(100) DEFAULT NULL, + billing_customer_id INT DEFAULT NULL, + shipping_customer_id INT DEFAULT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE customers ( + id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000), + name VARCHAR(100) DEFAULT NULL, + balance INT DEFAULT 0, + address_street VARCHAR(100) DEFAULT NULL, + address_city VARCHAR(100) DEFAULT NULL, + address_country VARCHAR(100) DEFAULT NULL, + gps_location VARCHAR(100) DEFAULT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE movies ( + movieid INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000), + name VARCHAR(100) DEFAULT NULL, + PRIMARY KEY (movieid) +); + +CREATE TABLE subscribers ( + nick VARCHAR(100) NOT NULL, + name VARCHAR(100) DEFAULT NULL, + PRIMARY KEY (nick) +); + +CREATE TABLE booleantests ( + id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000), + value INT DEFAULT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE auto_id_tests ( + auto_id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000), + value INT DEFAULT NULL, + PRIMARY KEY (auto_id) +); + +CREATE TABLE entrants ( + id INT NOT NULL PRIMARY KEY, + name VARCHAR(255) NOT NULL, + course_id INT NOT NULL +); + +CREATE TABLE colnametests ( + id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000), + references INT NOT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE mixins ( + id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000), + parent_id INT DEFAULT NULL, + pos INT DEFAULT NULL, + created_at TIMESTAMP DEFAULT NULL, + updated_at TIMESTAMP DEFAULT NULL, + lft INT DEFAULT NULL, + rgt INT DEFAULT NULL, + root_id INT DEFAULT NULL, + type VARCHAR(40) DEFAULT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE people ( + id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000), + first_name VARCHAR(40) NOT NULL, + lock_version INT DEFAULT 0, + PRIMARY KEY (id) +); + +CREATE TABLE readers ( + id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000), + post_id INT NOT NULL, + person_id INT NOT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE binaries ( + id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000), + data BLOB(50000), + PRIMARY KEY (id) +); + +CREATE TABLE computers ( + id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000), + developer INT NOT NULL, + extendedWarranty INT NOT NULL +); + +CREATE TABLE posts ( + id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000), + author_id INT DEFAULT NULL, + title VARCHAR(255) DEFAULT NULL, + type VARCHAR(255) DEFAULT NULL, + body VARCHAR(3000) DEFAULT NULL +); + +CREATE TABLE comments ( + id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000), + post_id INT DEFAULT NULL, + type VARCHAR(255) DEFAULT NULL, + body VARCHAR(3000) DEFAULT NULL +); + +CREATE TABLE authors ( + id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000), + name VARCHAR(255) DEFAULT NULL +); + +CREATE TABLE tasks ( + id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000), + starting TIMESTAMP DEFAULT NULL, + ending TIMESTAMP DEFAULT NULL +); + +CREATE TABLE categories ( + id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000), + name VARCHAR(255) NOT NULL, + type VARCHAR(40) DEFAULT NULL +); + +CREATE TABLE categories_posts ( + category_id INT NOT NULL, + post_id INT NOT NULL +); + +CREATE TABLE keyboards ( + key_number INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000), + name VARCHAR(255) +); + +CREATE TABLE fk_test_has_pk ( + id INT NOT NULL PRIMARY KEY +); + +CREATE TABLE fk_test_has_fk ( + id INT NOT NULL PRIMARY KEY, + fk_id INT NOT NULL, + + FOREIGN KEY (fk_id) REFERENCES fk_test_has_pk(id) +); + +--This table has an altered lock_version column name +CREATE TABLE legacy_things ( + id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000), + tps_report_number INT DEFAULT NULL, + version INT DEFAULT 0, + PRIMARY KEY (id) +); + +CREATE TABLE numeric_data ( + id INT NOT NULL PRIMARY KEY, + bank_balance DECIMAL(10,2), + big_bank_balance DECIMAL(15,2), + world_population DECIMAL(10), + my_house_population DECIMAL(2), + decimal_number_with_default DECIMAL(3,2) DEFAULT 2.78 +); + +CREATE TABLE mixed_case_monkeys ( + monkeyID INT NOT NULL PRIMARY KEY, + fleaCount INT +); + +CREATE TABLE minimalistics ( + id INT NOT NULL PRIMARY KEY +); diff --git a/activerecord/test/schema/db22.drop.sql b/activerecord/test/schema/db22.drop.sql new file mode 100644 index 0000000000..09681bf446 --- /dev/null +++ b/activerecord/test/schema/db22.drop.sql @@ -0,0 +1 @@ +DROP TABLE courses; diff --git a/activerecord/test/schema/db22.sql b/activerecord/test/schema/db22.sql new file mode 100644 index 0000000000..246ca0f6c4 --- /dev/null +++ b/activerecord/test/schema/db22.sql @@ -0,0 +1,4 @@ +CREATE TABLE courses ( + id INT NOT NULL PRIMARY KEY, + name VARCHAR(255) NOT NULL +); diff --git a/activerecord/test/schema/firebird.drop.sql b/activerecord/test/schema/firebird.drop.sql new file mode 100644 index 0000000000..378843bf9b --- /dev/null +++ b/activerecord/test/schema/firebird.drop.sql @@ -0,0 +1,65 @@ +DROP TABLE accounts; +DROP TABLE funny_jokes; +DROP TABLE companies; +DROP TABLE topics; +DROP TABLE developers; +DROP TABLE projects; +DROP TABLE developers_projects; +DROP TABLE orders; +DROP TABLE customers; +DROP TABLE movies; +DROP TABLE subscribers; +DROP TABLE booleantests; +DROP TABLE auto_id_tests; +DROP TABLE entrants; +DROP TABLE colnametests; +DROP TABLE mixins; +DROP TABLE people; +DROP TABLE readers; +DROP TABLE binaries; +DROP TABLE computers; +DROP TABLE posts; +DROP TABLE comments; +DROP TABLE authors; +DROP TABLE tasks; +DROP TABLE categories; +DROP TABLE categories_posts; +DROP TABLE fk_test_has_fk; +DROP TABLE fk_test_has_pk; +DROP TABLE keyboards; +DROP TABLE defaults; +DROP TABLE legacy_things; +DROP TABLE numeric_data; +DROP TABLE mixed_case_monkeys; +DROP TABLE minimalistics; + +DROP DOMAIN D_BOOLEAN; + +DROP GENERATOR accounts_seq; +DROP GENERATOR funny_jokes_seq; +DROP GENERATOR companies_nonstd_seq; +DROP GENERATOR topics_seq; +DROP GENERATOR developers_seq; +DROP GENERATOR projects_seq; +DROP GENERATOR orders_seq; +DROP GENERATOR customers_seq; +DROP GENERATOR movies_seq; +DROP GENERATOR booleantests_seq; +DROP GENERATOR auto_id_tests_seq; +DROP GENERATOR entrants_seq; +DROP GENERATOR colnametests_seq; +DROP GENERATOR mixins_seq; +DROP GENERATOR people_seq; +DROP GENERATOR binaries_seq; +DROP GENERATOR computers_seq; +DROP GENERATOR posts_seq; +DROP GENERATOR comments_seq; +DROP GENERATOR authors_seq; +DROP GENERATOR tasks_seq; +DROP GENERATOR categories_seq; +DROP GENERATOR keyboards_seq; +DROP GENERATOR defaults_seq; +DROP GENERATOR legacy_things_seq; +DROP GENERATOR numeric_data_seq; +DROP GENERATOR mixed_case_monkeys_seq; +DROP GENERATOR minimalistics_seq; diff --git a/activerecord/test/schema/firebird.sql b/activerecord/test/schema/firebird.sql new file mode 100644 index 0000000000..9ed6453ff7 --- /dev/null +++ b/activerecord/test/schema/firebird.sql @@ -0,0 +1,310 @@ +CREATE DOMAIN D_BOOLEAN AS SMALLINT CHECK (VALUE IN (0, 1) OR VALUE IS NULL); + +CREATE TABLE accounts ( + id BIGINT NOT NULL, + firm_id BIGINT, + credit_limit INTEGER, + PRIMARY KEY (id) +); +CREATE GENERATOR accounts_seq; +SET GENERATOR accounts_seq TO 10000; + +CREATE TABLE funny_jokes ( + id BIGINT NOT NULL, + name VARCHAR(50), + PRIMARY KEY (id) +); +CREATE GENERATOR funny_jokes_seq; +SET GENERATOR funny_jokes_seq TO 10000; + +CREATE TABLE companies ( + id BIGINT NOT NULL, + "TYPE" VARCHAR(50), + ruby_type VARCHAR(50), + firm_id BIGINT, + name VARCHAR(50), + client_of INTEGER, + rating INTEGER DEFAULT 1, + PRIMARY KEY (id) +); +CREATE GENERATOR companies_nonstd_seq; +SET GENERATOR companies_nonstd_seq TO 10000; + +CREATE TABLE topics ( + id BIGINT NOT NULL, + title VARCHAR(255), + author_name VARCHAR(255), + author_email_address VARCHAR(255), + written_on TIMESTAMP, + bonus_time TIME, + last_read DATE, + content VARCHAR(4000), + approved D_BOOLEAN DEFAULT 1, + replies_count INTEGER DEFAULT 0, + parent_id BIGINT, + "TYPE" VARCHAR(50), + PRIMARY KEY (id) +); +CREATE GENERATOR topics_seq; +SET GENERATOR topics_seq TO 10000; + +CREATE TABLE developers ( + id BIGINT NOT NULL, + name VARCHAR(100), + salary INTEGER DEFAULT 70000, + created_at TIMESTAMP, + updated_at TIMESTAMP, + PRIMARY KEY (id) +); +CREATE GENERATOR developers_seq; +SET GENERATOR developers_seq TO 10000; + +CREATE TABLE projects ( + id BIGINT NOT NULL, + name VARCHAR(100), + "TYPE" VARCHAR(255), + PRIMARY KEY (id) +); +CREATE GENERATOR projects_seq; +SET GENERATOR projects_seq TO 10000; + +CREATE TABLE developers_projects ( + developer_id BIGINT NOT NULL, + project_id BIGINT NOT NULL, + joined_on DATE, + access_level SMALLINT DEFAULT 1 +); + +CREATE TABLE orders ( + id BIGINT NOT NULL, + name VARCHAR(100), + billing_customer_id BIGINT, + shipping_customer_id BIGINT, + PRIMARY KEY (id) +); +CREATE GENERATOR orders_seq; +SET GENERATOR orders_seq TO 10000; + +CREATE TABLE customers ( + id BIGINT NOT NULL, + name VARCHAR(100), + balance INTEGER DEFAULT 0, + address_street VARCHAR(100), + address_city VARCHAR(100), + address_country VARCHAR(100), + gps_location VARCHAR(100), + PRIMARY KEY (id) +); +CREATE GENERATOR customers_seq; +SET GENERATOR customers_seq TO 10000; + +CREATE TABLE movies ( + movieid BIGINT NOT NULL, + name varchar(100), + PRIMARY KEY (movieid) +); +CREATE GENERATOR movies_seq; +SET GENERATOR movies_seq TO 10000; + +CREATE TABLE subscribers ( + nick VARCHAR(100) NOT NULL, + name VARCHAR(100), + PRIMARY KEY (nick) +); + +CREATE TABLE booleantests ( + id BIGINT NOT NULL, + "VALUE" D_BOOLEAN, + PRIMARY KEY (id) +); +CREATE GENERATOR booleantests_seq; +SET GENERATOR booleantests_seq TO 10000; + +CREATE TABLE auto_id_tests ( + auto_id BIGINT NOT NULL, + "VALUE" INTEGER, + PRIMARY KEY (auto_id) +); +CREATE GENERATOR auto_id_tests_seq; +SET GENERATOR auto_id_tests_seq TO 10000; + +CREATE TABLE entrants ( + id BIGINT NOT NULL, + name VARCHAR(255) NOT NULL, + course_id INTEGER NOT NULL, + PRIMARY KEY (id) +); +CREATE GENERATOR entrants_seq; +SET GENERATOR entrants_seq TO 10000; + +CREATE TABLE colnametests ( + id BIGINT NOT NULL, + "REFERENCES" INTEGER NOT NULL, + PRIMARY KEY (id) +); +CREATE GENERATOR colnametests_seq; +SET GENERATOR colnametests_seq TO 10000; + +CREATE TABLE mixins ( + id BIGINT NOT NULL, + parent_id BIGINT, + pos INTEGER, + created_at TIMESTAMP, + updated_at TIMESTAMP, + lft INTEGER, + rgt INTEGER, + root_id BIGINT, + "TYPE" VARCHAR(40), + PRIMARY KEY (id) +); +CREATE GENERATOR mixins_seq; +SET GENERATOR mixins_seq TO 10000; + +CREATE TABLE people ( + id BIGINT NOT NULL, + first_name VARCHAR(40), + lock_version INTEGER DEFAULT 0 NOT NULL, + PRIMARY KEY (id) +); +CREATE GENERATOR people_seq; +SET GENERATOR people_seq TO 10000; + +CREATE TABLE readers ( + id BIGINT NOT NULL, + post_id BIGINT NOT NULL, + person_id BIGINT NOT NULL, + PRIMARY KEY (id) +); +CREATE GENERATOR readers_seq; +SET GENERATOR readers_seq TO 10000; + +CREATE TABLE binaries ( + id BIGINT NOT NULL, + data BLOB, + PRIMARY KEY (id) +); +CREATE GENERATOR binaries_seq; +SET GENERATOR binaries_seq TO 10000; + +CREATE TABLE computers ( + id BIGINT NOT NULL, + developer INTEGER NOT NULL, + "extendedWarranty" INTEGER NOT NULL, + PRIMARY KEY (id) +); +CREATE GENERATOR computers_seq; +SET GENERATOR computers_seq TO 10000; + +CREATE TABLE posts ( + id BIGINT NOT NULL, + author_id BIGINT, + title VARCHAR(255) NOT NULL, + "TYPE" VARCHAR(255) NOT NULL, + body VARCHAR(3000) NOT NULL, + PRIMARY KEY (id) +); +CREATE GENERATOR posts_seq; +SET GENERATOR posts_seq TO 10000; + +CREATE TABLE comments ( + id BIGINT NOT NULL, + post_id BIGINT NOT NULL, + "TYPE" VARCHAR(255) NOT NULL, + body VARCHAR(3000) NOT NULL, + PRIMARY KEY (id) +); +CREATE GENERATOR comments_seq; +SET GENERATOR comments_seq TO 10000; + +CREATE TABLE authors ( + id BIGINT NOT NULL, + name VARCHAR(255) NOT NULL, + PRIMARY KEY (id) +); +CREATE GENERATOR authors_seq; +SET GENERATOR authors_seq TO 10000; + +CREATE TABLE tasks ( + id BIGINT NOT NULL, + "STARTING" TIMESTAMP, + ending TIMESTAMP, + PRIMARY KEY (id) +); +CREATE GENERATOR tasks_seq; +SET GENERATOR tasks_seq TO 10000; + +CREATE TABLE categories ( + id BIGINT NOT NULL, + name VARCHAR(255) NOT NULL, + "TYPE" VARCHAR(255) NOT NULL, + PRIMARY KEY (id) +); +CREATE GENERATOR categories_seq; +SET GENERATOR categories_seq TO 10000; + +CREATE TABLE categories_posts ( + category_id BIGINT NOT NULL, + post_id BIGINT NOT NULL, + PRIMARY KEY (category_id, post_id) +); + +CREATE TABLE fk_test_has_pk ( + id BIGINT NOT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE fk_test_has_fk ( + id BIGINT NOT NULL, + fk_id BIGINT NOT NULL, + PRIMARY KEY (id), + FOREIGN KEY (fk_id) REFERENCES fk_test_has_pk(id) +); + +CREATE TABLE keyboards ( + key_number BIGINT NOT NULL, + name VARCHAR(50), + PRIMARY KEY (key_number) +); +CREATE GENERATOR keyboards_seq; +SET GENERATOR keyboards_seq TO 10000; + +CREATE TABLE defaults ( + id BIGINT NOT NULL, + default_timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); +CREATE GENERATOR defaults_seq; +SET GENERATOR defaults_seq TO 10000; + +CREATE TABLE legacy_things ( + id BIGINT NOT NULL, + tps_report_number INTEGER, + version INTEGER DEFAULT 0 NOT NULL, + PRIMARY KEY (id) +); +CREATE GENERATOR legacy_things_seq; +SET GENERATOR legacy_things_seq TO 10000; + +CREATE TABLE numeric_data ( + id BIGINT NOT NULL, + bank_balance DECIMAL(10,2), + big_bank_balance DECIMAL(15,2), + world_population DECIMAL(10), + my_house_population DECIMAL(2), + decimal_number_with_default DECIMAL(3,2) DEFAULT 2.78, + PRIMARY KEY (id) +); +CREATE GENERATOR numeric_data_seq; +SET GENERATOR numeric_data_seq TO 10000; + +CREATE TABLE mixed_case_monkeys ( + "monkeyID" BIGINT NOT NULL, + "fleaCount" INTEGER +); +CREATE GENERATOR mixed_case_monkeys_seq; +SET GENERATOR mixed_case_monkeys_seq TO 10000; + +CREATE TABLE minimalistics ( + id BIGINT NOT NULL +); +CREATE GENERATOR minimalistics_seq; +SET GENERATOR minimalistics_seq TO 10000; diff --git a/activerecord/test/schema/firebird2.drop.sql b/activerecord/test/schema/firebird2.drop.sql new file mode 100644 index 0000000000..c59fb1f2ff --- /dev/null +++ b/activerecord/test/schema/firebird2.drop.sql @@ -0,0 +1,2 @@ +DROP TABLE courses; +DROP GENERATOR courses_seq; diff --git a/activerecord/test/schema/firebird2.sql b/activerecord/test/schema/firebird2.sql new file mode 100644 index 0000000000..c1bc251fbc --- /dev/null +++ b/activerecord/test/schema/firebird2.sql @@ -0,0 +1,6 @@ +CREATE TABLE courses ( + id BIGINT NOT NULL PRIMARY KEY, + name VARCHAR(255) NOT NULL +); +CREATE GENERATOR courses_seq; +SET GENERATOR courses_seq TO 10000; diff --git a/activerecord/test/schema/frontbase.drop.sql b/activerecord/test/schema/frontbase.drop.sql new file mode 100644 index 0000000000..58ec56bd4f --- /dev/null +++ b/activerecord/test/schema/frontbase.drop.sql @@ -0,0 +1,33 @@ +DROP TABLE accounts CASCADE; +DROP TABLE funny_jokes CASCADE; +DROP TABLE companies CASCADE; +DROP TABLE topics CASCADE; +DROP TABLE developers CASCADE; +DROP TABLE projects CASCADE; +DROP TABLE developers_projects CASCADE; +DROP TABLE orders CASCADE; +DROP TABLE customers CASCADE; +DROP TABLE movies CASCADE; +DROP TABLE subscribers CASCADE; +DROP TABLE booleantests CASCADE; +DROP TABLE auto_id_tests CASCADE; +DROP TABLE entrants CASCADE; +DROP TABLE colnametests CASCADE; +DROP TABLE mixins CASCADE; +DROP TABLE people CASCADE; +DROP TABLE readers CASCADE; +DROP TABLE binaries CASCADE; +DROP TABLE computers CASCADE; +DROP TABLE posts CASCADE; +DROP TABLE comments CASCADE; +DROP TABLE authors CASCADE; +DROP TABLE tasks CASCADE; +DROP TABLE categories CASCADE; +DROP TABLE categories_posts CASCADE; +DROP TABLE fk_test_has_fk CASCADE; +DROP TABLE fk_test_has_pk CASCADE; +DROP TABLE keyboards CASCADE; +DROP TABLE legacy_things CASCADE; +DROP TABLE numeric_data CASCADE; +DROP TABLE mixed_case_monkeys CASCADE; +DROP TABLE minimalistics CASCADE; diff --git a/activerecord/test/schema/frontbase.sql b/activerecord/test/schema/frontbase.sql new file mode 100644 index 0000000000..6945a385c6 --- /dev/null +++ b/activerecord/test/schema/frontbase.sql @@ -0,0 +1,273 @@ +CREATE TABLE accounts ( + id integer DEFAULT unique, + firm_id integer, + credit_limit integer, + PRIMARY KEY (id) +); +SET UNIQUE FOR accounts(id); + +CREATE TABLE funny_jokes ( + id integer DEFAULT unique, + firm_id integer default NULL, + name character varying(50), + PRIMARY KEY (id) +); +SET UNIQUE FOR funny_jokes(id); + +CREATE TABLE companies ( + id integer DEFAULT unique, + "type" character varying(50), + "ruby_type" character varying(50), + firm_id integer, + name character varying(50), + client_of integer, + rating integer default 1, + PRIMARY KEY (id) +); +SET UNIQUE FOR companies(id); + +CREATE TABLE topics ( + id integer DEFAULT unique, + title character varying(255), + author_name character varying(255), + author_email_address character varying(255), + written_on timestamp, + bonus_time time, + last_read date, + content varchar(65536), + approved boolean default true, + replies_count integer default 0, + parent_id integer, + "type" character varying(50), + PRIMARY KEY (id) +); +SET UNIQUE FOR topics(id); + +CREATE TABLE developers ( + id integer DEFAULT unique, + name character varying(100), + salary integer DEFAULT 70000, + created_at timestamp, + updated_at timestamp, + PRIMARY KEY (id) +); +SET UNIQUE FOR developers(id); + +CREATE TABLE projects ( + id integer DEFAULT unique, + name character varying(100), + type varchar(255), + PRIMARY KEY (id) +); +SET UNIQUE FOR projects(id); + +CREATE TABLE developers_projects ( + developer_id integer NOT NULL, + project_id integer NOT NULL, + joined_on date, + access_level integer default 1 +); + +CREATE TABLE orders ( + id integer DEFAULT unique, + name character varying(100), + billing_customer_id integer, + shipping_customer_id integer, + PRIMARY KEY (id) +); +SET UNIQUE FOR orders(id); + +CREATE TABLE customers ( + id integer DEFAULT unique, + name character varying(100), + balance integer default 0, + address_street character varying(100), + address_city character varying(100), + address_country character varying(100), + gps_location character varying(100), + PRIMARY KEY (id) +); +SET UNIQUE FOR customers(id); + +CREATE TABLE movies ( + movieid integer DEFAULT unique, + name varchar(65536), + PRIMARY KEY (movieid) +); +SET UNIQUE FOR movies(movieid); + +CREATE TABLE subscribers ( + nick varchar(65536) NOT NULL, + name varchar(65536), + PRIMARY KEY (nick) +); + +CREATE TABLE booleantests ( + id integer DEFAULT unique, + value boolean, + PRIMARY KEY (id) +); +SET UNIQUE FOR booleantests(id); + +CREATE TABLE auto_id_tests ( + auto_id integer DEFAULT unique, + value integer, + PRIMARY KEY (auto_id) +); +SET UNIQUE FOR auto_id_tests(auto_id); + +CREATE TABLE entrants ( + id integer DEFAULT unique, + name varchar(65536), + course_id integer, + PRIMARY KEY (id) +); +SET UNIQUE FOR entrants(id); + +CREATE TABLE colnametests ( + id integer DEFAULT unique, + "references" integer NOT NULL, + PRIMARY KEY (id) +); +SET UNIQUE FOR colnametests(id); + +CREATE TABLE mixins ( + id integer DEFAULT unique, + parent_id integer, + type character varying(100), + pos integer, + lft integer, + rgt integer, + root_id integer, + created_at timestamp, + updated_at timestamp, + PRIMARY KEY (id) +); +SET UNIQUE FOR mixins(id); + +CREATE TABLE people ( + id integer DEFAULT unique, + first_name varchar(65536), + lock_version integer default 0, + PRIMARY KEY (id) +); +SET UNIQUE FOR people(id); + +CREATE TABLE readers ( + id integer DEFAULT unique, + post_id INTEGER NOT NULL, + person_id INTEGER NOT NULL, + PRIMARY KEY (id) +); +SET UNIQUE FOR readers(id); + +CREATE TABLE binaries ( + id integer DEFAULT unique, + data BLOB, + PRIMARY KEY (id) +); +SET UNIQUE FOR binaries(id); + +CREATE TABLE computers ( + id integer DEFAULT unique, + developer integer NOT NULL, + "extendedWarranty" integer NOT NULL, + PRIMARY KEY (id) +); +SET UNIQUE FOR computers(id); + +CREATE TABLE posts ( + id integer DEFAULT unique, + author_id integer, + title varchar(255), + type varchar(255), + body varchar(65536), + PRIMARY KEY (id) +); +SET UNIQUE FOR posts(id); + +CREATE TABLE comments ( + id integer DEFAULT unique, + post_id integer, + type varchar(255), + body varchar(65536), + PRIMARY KEY (id) +); +SET UNIQUE FOR comments(id); + +CREATE TABLE authors ( + id integer DEFAULT unique, + name varchar(255) default NULL, + PRIMARY KEY (id) +); +SET UNIQUE FOR authors(id); + +CREATE TABLE tasks ( + id integer DEFAULT unique, + starting timestamp, + ending timestamp, + PRIMARY KEY (id) +); +SET UNIQUE FOR tasks(id); + +CREATE TABLE categories ( + id integer DEFAULT unique, + name varchar(255), + type varchar(255), + PRIMARY KEY (id) +); +SET UNIQUE FOR categories(id); + +CREATE TABLE categories_posts ( + category_id integer NOT NULL, + post_id integer NOT NULL +); + +CREATE TABLE fk_test_has_pk ( + id INTEGER NOT NULL PRIMARY KEY +); +SET UNIQUE FOR fk_test_has_pk(id); + +CREATE TABLE fk_test_has_fk ( + id INTEGER NOT NULL PRIMARY KEY, + fk_id INTEGER NOT NULL REFERENCES fk_test_has_fk(id) +); +SET UNIQUE FOR fk_test_has_fk(id); + +CREATE TABLE keyboards ( + key_number integer DEFAULT unique, + "name" character varying(50), + PRIMARY KEY (key_number) +); +SET UNIQUE FOR keyboards(key_number); + +create table "legacy_things" +( + "id" int, + "tps_report_number" int default NULL, + "version" int default 0 not null, + primary key ("id") +); +SET UNIQUE FOR legacy_things(id); + +CREATE TABLE "numeric_data" ( + "id" integer NOT NULL + "bank_balance" DECIMAL(10,2), + "big_bank_balance" DECIMAL(15,2), + "world_population" DECIMAL(10), + "my_house_population" DECIMAL(2), + "decimal_number_with_default" DECIMAL(3,2) DEFAULT 2.78, + primary key ("id") +); +SET UNIQUE FOR numeric_data(id); + +CREATE TABLE mixed_case_monkeys ( + "monkeyID" integer DEFAULT unique, + "fleaCount" integer +); +SET UNIQUE FOR mixed_case_monkeys("monkeyID"); + +CREATE TABLE minimalistics ( + "id" integer NOT NULL +); +SET UNIQUE FOR minimalistics("id"); diff --git a/activerecord/test/schema/frontbase2.drop.sql b/activerecord/test/schema/frontbase2.drop.sql new file mode 100644 index 0000000000..17b9ad46d7 --- /dev/null +++ b/activerecord/test/schema/frontbase2.drop.sql @@ -0,0 +1 @@ +DROP TABLE courses CASCADE; diff --git a/activerecord/test/schema/frontbase2.sql b/activerecord/test/schema/frontbase2.sql new file mode 100644 index 0000000000..80063b5989 --- /dev/null +++ b/activerecord/test/schema/frontbase2.sql @@ -0,0 +1,4 @@ +CREATE TABLE courses ( + id integer DEFAULT unique, + name varchar(100) +); diff --git a/activerecord/test/schema/openbase.drop.sql b/activerecord/test/schema/openbase.drop.sql new file mode 100644 index 0000000000..fb40e3f213 --- /dev/null +++ b/activerecord/test/schema/openbase.drop.sql @@ -0,0 +1,2 @@ +DROP ALL +go \ No newline at end of file diff --git a/activerecord/test/schema/openbase.sql b/activerecord/test/schema/openbase.sql new file mode 100644 index 0000000000..cb804ae7b2 --- /dev/null +++ b/activerecord/test/schema/openbase.sql @@ -0,0 +1,318 @@ +CREATE TABLE accounts ( + id integer NOT NULL UNIQUE INDEX DEFAULT _rowid, + firm_id integer, + credit_limit integer +) +go +CREATE PRIMARY KEY accounts (id) +go + +CREATE TABLE funny_jokes ( + id integer NOT NULL UNIQUE INDEX DEFAULT _rowid, + name char(50) DEFAULT NULL +) +go +CREATE PRIMARY KEY funny_jokes (id) +go + +CREATE TABLE companies ( + id integer NOT NULL UNIQUE INDEX DEFAULT _rowid, + type char(50), + ruby_type char(50), + firm_id integer, + name char(50), + client_of integer, + rating integer default 1 +) +go +CREATE PRIMARY KEY companies (id) +go + +CREATE TABLE developers_projects ( + developer_id integer NOT NULL, + project_id integer NOT NULL, + joined_on date, + access_level integer default 1 +) +go + +CREATE TABLE developers ( + id integer NOT NULL UNIQUE INDEX DEFAULT _rowid, + name char(100), + salary integer DEFAULT 70000, + created_at datetime, + updated_at datetime +) +go +CREATE PRIMARY KEY developers (id) +go + +CREATE TABLE projects ( + id integer NOT NULL UNIQUE INDEX DEFAULT _rowid, + name char(100), + type char(255) +) +go +CREATE PRIMARY KEY projects (id) +go + +CREATE TABLE topics ( + id integer NOT NULL UNIQUE INDEX DEFAULT _rowid, + title char(255), + author_name char(255), + author_email_address char(255), + written_on datetime, + bonus_time time, + last_read date, + content char(4096), + approved boolean default true, + replies_count integer default 0, + parent_id integer, + type char(50) +) +go +CREATE PRIMARY KEY topics (id) +go + +CREATE TABLE customers ( + id integer NOT NULL UNIQUE INDEX DEFAULT _rowid, + name char, + balance integer default 0, + address_street char, + address_city char, + address_country char, + gps_location char +) +go +CREATE PRIMARY KEY customers (id) +go + +CREATE TABLE orders ( + id integer NOT NULL UNIQUE INDEX DEFAULT _rowid, + name char, + billing_customer_id integer, + shipping_customer_id integer +) +go +CREATE PRIMARY KEY orders (id) +go + +CREATE TABLE movies ( + movieid integer NOT NULL UNIQUE INDEX DEFAULT _rowid, + name text +) +go +CREATE PRIMARY KEY movies (movieid) +go + +CREATE TABLE subscribers ( + nick CHAR(100) NOT NULL DEFAULT _rowid, + name CHAR(100) +) +go +CREATE PRIMARY KEY subscribers (nick) +go + +CREATE TABLE booleantests ( + id integer NOT NULL UNIQUE INDEX DEFAULT _rowid, + value boolean +) +go +CREATE PRIMARY KEY booleantests (id) +go + +CREATE TABLE defaults ( + id integer UNIQUE INDEX , + modified_date date default CURDATE(), + modified_date_function date default NOW(), + fixed_date date default '2004-01-01', + modified_time timestamp default NOW(), + modified_time_function timestamp default NOW(), + fixed_time timestamp default '2004-01-01 00:00:00.000000-00', + char1 char(1) default 'Y', + char2 char(50) default 'a char field', + char3 text default 'a text field', + positive_integer integer default 1, + negative_integer integer default -1, + decimal_number money default 2.78 +) +go +CREATE PRIMARY KEY defaults (id) +go + +CREATE TABLE auto_id_tests ( + auto_id integer NOT NULL UNIQUE INDEX DEFAULT _rowid, + value integer +) +go +CREATE PRIMARY KEY auto_id_tests (auto_id) +go + +CREATE TABLE entrants ( + id integer NOT NULL UNIQUE INDEX, + name text NOT NULL, + course_id integer NOT NULL +) +go +CREATE PRIMARY KEY entrants (id) +go + +CREATE TABLE colnametests ( + id integer UNIQUE INDEX , + references integer NOT NULL +) +go +CREATE PRIMARY KEY colnametests (id) +go + +CREATE TABLE mixins ( + id integer NOT NULL UNIQUE INDEX DEFAULT _rowid, + parent_id integer, + type char, + pos integer, + lft integer, + rgt integer, + root_id integer, + created_at timestamp, + updated_at timestamp +) +go +CREATE PRIMARY KEY mixins (id) +go + +CREATE TABLE people ( + id integer NOT NULL UNIQUE INDEX DEFAULT _rowid, + first_name text, + lock_version integer default 0 +) +go +CREATE PRIMARY KEY people (id) +go + +CREATE TABLE readers ( + id integer NOT NULL UNIQUE INDEX DEFAULT _rowid, + post_id integer NOT NULL, + person_id integer NOT NULL +) +go +CREATE PRIMARY KEY readers (id) +go + +CREATE TABLE binaries ( + id integer NOT NULL UNIQUE INDEX DEFAULT _rowid, + data object +) +go +CREATE PRIMARY KEY binaries (id) +go + +CREATE TABLE computers ( + id integer UNIQUE INDEX , + developer integer NOT NULL, + extendedWarranty integer NOT NULL +) +go + +CREATE TABLE posts ( + id integer UNIQUE INDEX , + author_id integer, + title char(255), + type char(255), + body text +) +go + +CREATE TABLE comments ( + id integer UNIQUE INDEX , + post_id integer, + type char(255), + body text +) +go + +CREATE TABLE authors ( + id integer UNIQUE INDEX , + name char(255) default NULL +) +go + +CREATE TABLE tasks ( + id integer NOT NULL UNIQUE INDEX DEFAULT _rowid, + starting datetime, + ending datetime +) +go +CREATE PRIMARY KEY tasks (id) +go + +CREATE TABLE categories ( + id integer UNIQUE INDEX , + name char(255), + type char(255) +) +go + +CREATE TABLE categories_posts ( + category_id integer NOT NULL, + post_id integer NOT NULL +) +go + +CREATE TABLE fk_test_has_pk ( + id INTEGER NOT NULL DEFAULT _rowid +) +go +CREATE PRIMARY KEY fk_test_has_pk (id) +go + +CREATE TABLE fk_test_has_fk ( + id INTEGER NOT NULL DEFAULT _rowid, + fk_id INTEGER NOT NULL REFERENCES fk_test_has_pk.id +) +go +CREATE PRIMARY KEY fk_test_has_fk (id) +go + +CREATE TABLE keyboards ( + key_number integer UNIQUE INDEX DEFAULT _rowid, + name char(50) +) +go +CREATE PRIMARY KEY keyboards (key_number) +go + +CREATE TABLE legacy_things ( + id INTEGER NOT NULL DEFAULT _rowid, + tps_report_number INTEGER default NULL, + version integer NOT NULL default 0 +) +go +CREATE PRIMARY KEY legacy_things (id) +go + +CREATE TABLE numeric_data ( + id INTEGER NOT NULL DEFAULT _rowid, + bank_balance MONEY, + big_bank_balance MONEY, + world_population longlong, + my_house_population longlong, + decimal_number_with_default MONEY DEFAULT 2.78 +); +go +CREATE PRIMARY KEY numeric_data (id) +go + +CREATE TABLE mixed_case_monkeys ( + monkeyID INTEGER NOT NULL DEFAULT _rowid, + fleaCount INTEGER +); +go +CREATE PRIMARY KEY mixed_case_monkeys (monkeyID) +go + +CREATE TABLE minimalistics ( + id INTEGER NOT NULL DEFAULT _rowid +); +go +CREATE PRIMARY KEY minimalistics (id) +go diff --git a/activerecord/test/schema/openbase2.drop.sql b/activerecord/test/schema/openbase2.drop.sql new file mode 100644 index 0000000000..ea1571da0b --- /dev/null +++ b/activerecord/test/schema/openbase2.drop.sql @@ -0,0 +1,2 @@ +DROP TABLE courses +go diff --git a/activerecord/test/schema/openbase2.sql b/activerecord/test/schema/openbase2.sql new file mode 100644 index 0000000000..a37c4f4c31 --- /dev/null +++ b/activerecord/test/schema/openbase2.sql @@ -0,0 +1,7 @@ +CREATE TABLE courses ( + id integer UNIQUE INDEX DEFAULT _rowid, + name text +) +go +CREATE PRIMARY KEY courses (id) +go \ No newline at end of file diff --git a/activerecord/test/schema/oracle.drop.sql b/activerecord/test/schema/oracle.drop.sql new file mode 100644 index 0000000000..21f40ed8d0 --- /dev/null +++ b/activerecord/test/schema/oracle.drop.sql @@ -0,0 +1,67 @@ +drop table accounts; +drop table funny_jokes; +drop table companies; +drop table topics; +drop synonym subjects; +drop table developers_projects; +drop table computers; +drop table developers; +drop table projects; +drop table customers; +drop table orders; +drop table movies; +drop table subscribers; +drop table booleantests; +drop table auto_id_tests; +drop table entrants; +drop table colnametests; +drop table mixins; +drop table people; +drop table readers; +drop table binaries; +drop table comments; +drop table authors; +drop table tasks; +drop table categories_posts; +drop table categories; +drop table posts; +drop table fk_test_has_pk; +drop table fk_test_has_fk; +drop table keyboards; +drop table legacy_things; +drop table numeric_data; +drop table mixed_case_monkeys; +drop table minimalistics; + +drop sequence accounts_seq; +drop sequence funny_jokes_seq; +drop sequence companies_nonstd_seq; +drop sequence topics_seq; +drop sequence developers_seq; +drop sequence projects_seq; +drop sequence developers_projects_seq; +drop sequence customers_seq; +drop sequence orders_seq; +drop sequence movies_seq; +drop sequence subscribers_seq; +drop sequence booleantests_seq; +drop sequence auto_id_tests_seq; +drop sequence entrants_seq; +drop sequence colnametests_seq; +drop sequence mixins_seq; +drop sequence people_seq; +drop sequence binaries_seq; +drop sequence posts_seq; +drop sequence comments_seq; +drop sequence authors_seq; +drop sequence tasks_seq; +drop sequence computers_seq; +drop sequence categories_seq; +drop sequence categories_posts_seq; +drop sequence fk_test_has_pk_seq; +drop sequence fk_test_has_fk_seq; +drop sequence keyboards_seq; +drop sequence legacy_things_seq; +drop sequence numeric_data_seq; +drop sequence mixed_case_monkeys_seq; +drop sequence minimalistics_seq; diff --git a/activerecord/test/schema/oracle.sql b/activerecord/test/schema/oracle.sql new file mode 100644 index 0000000000..22ca0baa8d --- /dev/null +++ b/activerecord/test/schema/oracle.sql @@ -0,0 +1,330 @@ +create table companies ( + id integer not null, + type varchar(50) default null, + ruby_type varchar(50) default null, + firm_id integer default null references companies initially deferred disable, + name varchar(50) default null, + client_of integer default null references companies initially deferred disable, + companies_count integer default 0, + rating integer default 1, + primary key (id) +); + +-- non-standard sequence name used to test set_sequence_name +-- +create sequence companies_nonstd_seq minvalue 10000; + +create table funny_jokes ( + id integer not null, + name varchar(50) default null, + primary key (id) +); +create sequence funny_jokes_seq minvalue 10000; + +create table accounts ( + id integer not null, + firm_id integer default null references companies initially deferred disable, + credit_limit integer default null +); +create sequence accounts_seq minvalue 10000; + +create table topics ( + id integer not null, + title varchar(255) default null, + author_name varchar(255) default null, + author_email_address varchar(255) default null, + written_on timestamp default null, + bonus_time timestamp default null, + last_read timestamp default null, + content varchar(4000), + approved number(1) default 1, + replies_count integer default 0, + parent_id integer references topics initially deferred disable, + type varchar(50) default null, + primary key (id) +); +-- try again for 8i +create table topics ( + id integer not null, + title varchar(255) default null, + author_name varchar(255) default null, + author_email_address varchar(255) default null, + written_on date default null, + bonus_time date default null, + last_read date default null, + content varchar(4000), + approved number(1) default 1, + replies_count integer default 0, + parent_id integer references topics initially deferred disable, + type varchar(50) default null, + primary key (id) +); +create sequence topics_seq minvalue 10000; + +create synonym subjects for topics; + +create table developers ( + id integer not null, + name varchar(100) default null, + salary integer default 70000, + created_at timestamp default null, + updated_at timestamp default null, + primary key (id) +); +create sequence developers_seq minvalue 10000; + +create table projects ( + id integer not null, + name varchar(100) default null, + type varchar(255) default null, + primary key (id) +); +create sequence projects_seq minvalue 10000; + +create table developers_projects ( + developer_id integer not null references developers initially deferred disable, + project_id integer not null references projects initially deferred disable, + joined_on timestamp default null, + access_level integer default 1 +); +-- Try again for 8i +create table developers_projects ( + developer_id integer not null references developers initially deferred disable, + project_id integer not null references projects initially deferred disable, + joined_on date default null +); +create sequence developers_projects_seq minvalue 10000; + +create table orders ( + id integer not null, + name varchar(100) default null, + billing_customer_id integer default null, + shipping_customer_id integer default null, + primary key (id) +); +create sequence orders_seq minvalue 10000; + +create table customers ( + id integer not null, + name varchar(100) default null, + balance integer default 0, + address_street varchar(100) default null, + address_city varchar(100) default null, + address_country varchar(100) default null, + gps_location varchar(100) default null, + primary key (id) +); +create sequence customers_seq minvalue 10000; + +create table movies ( + movieid integer not null, + name varchar(100) default null, + primary key (movieid) +); +create sequence movies_seq minvalue 10000; + +create table subscribers ( + nick varchar(100) not null, + name varchar(100) default null, + primary key (nick) +); +create sequence subscribers_seq minvalue 10000; + +create table booleantests ( + id integer not null, + value integer default null, + primary key (id) +); +create sequence booleantests_seq minvalue 10000; + +CREATE TABLE defaults ( + id integer not null, + modified_date date default sysdate, + modified_date_function date default sysdate, + fixed_date date default to_date('2004-01-01', 'YYYY-MM-DD'), + modified_time date default sysdate, + modified_time_function date default sysdate, + fixed_time date default TO_DATE('2004-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), + char1 varchar2(1) default 'Y', + char2 varchar2(50) default 'a varchar field', + char3 clob default 'a text field', + positive_integer integer default 1, + negative_integer integer default -1, + decimal_number number(3,2) default 2.78 +); +create sequence defaults_seq minvalue 10000; + +create table auto_id_tests ( + auto_id integer not null, + value integer default null, + primary key (auto_id) +); +create sequence auto_id_tests_seq minvalue 10000; + +create table entrants ( + id integer not null primary key, + name varchar(255) not null, + course_id integer not null +); +create sequence entrants_seq minvalue 10000; + +create table colnametests ( + id integer not null, + references integer not null, + primary key (id) +); +create sequence colnametests_seq minvalue 10000; + +create table mixins ( + id integer not null, + parent_id integer default null references mixins initially deferred disable, + type varchar(40) default null, + pos integer default null, + lft integer default null, + rgt integer default null, + root_id integer default null, + created_at timestamp default null, + updated_at timestamp default null, + primary key (id) +); +-- try again for 8i +create table mixins ( + id integer not null, + parent_id integer default null references mixins initially deferred disable, + type varchar(40) default null, + pos integer default null, + lft integer default null, + rgt integer default null, + root_id integer default null, + created_at date default null, + updated_at date default null, + primary key (id) +); +create sequence mixins_seq minvalue 10000; + +create table people ( + id integer not null, + first_name varchar(40) null, + lock_version integer default 0, + primary key (id) +); +create sequence people_seq minvalue 10000; + +create table readers ( + id integer not null, + post_id integer not null, + person_id integer not null, + primary key (id) +); +create sequence readers_seq minvalue 10000; + +create table binaries ( + id integer not null, + data blob null, + primary key (id) +); +create sequence binaries_seq minvalue 10000; + +create table computers ( + id integer not null primary key, + developer integer not null references developers initially deferred disable, + "extendedWarranty" integer not null +); +create sequence computers_seq minvalue 10000; + +create table posts ( + id integer not null primary key, + author_id integer default null, + title varchar(255) default null, + type varchar(255) default null, + body varchar(3000) default null +); +create sequence posts_seq minvalue 10000; + +create table comments ( + id integer not null primary key, + post_id integer default null, + type varchar(255) default null, + body varchar(3000) default null +); +create sequence comments_seq minvalue 10000; + +create table authors ( + id integer not null primary key, + name varchar(255) default null +); +create sequence authors_seq minvalue 10000; + +create table tasks ( + id integer not null primary key, + starting date default null, + ending date default null +); +create sequence tasks_seq minvalue 10000; + +create table categories ( + id integer not null primary key, + name varchar(255) default null, + type varchar(255) default null +); +create sequence categories_seq minvalue 10000; + +create table categories_posts ( + category_id integer not null references categories initially deferred disable, + post_id integer not null references posts initially deferred disable +); +create sequence categories_posts_seq minvalue 10000; + +create table fk_test_has_pk ( + id integer not null primary key +); +create sequence fk_test_has_pk_seq minvalue 10000; + +create table fk_test_has_fk ( + id integer not null primary key, + fk_id integer not null references fk_test_has_fk initially deferred disable +); +create sequence fk_test_has_fk_seq minvalue 10000; + +create table keyboards ( + key_number integer not null, + name varchar(50) default null +); +create sequence keyboards_seq minvalue 10000; + +create table test_oracle_defaults ( + id integer not null primary key, + test_char char(1) default 'X' not null, + test_string varchar2(20) default 'hello' not null, + test_int integer default 3 not null +); +create sequence test_oracle_defaults_seq minvalue 10000; + +--This table has an altered lock_version column name. +create table legacy_things ( + id integer not null primary key, + tps_report_number integer default null, + version integer default 0 +); +create sequence legacy_things_seq minvalue 10000; + +CREATE TABLE numeric_data ( + id integer NOT NULL PRIMARY KEY, + bank_balance decimal(10,2), + big_bank_balance decimal(15,2), + world_population decimal(10), + my_house_population decimal(2), + decimal_number_with_default decimal(3,2) DEFAULT 2.78 +); +create sequence numeric_data_seq minvalue 10000; + +CREATE TABLE mixed_case_monkeys ( + "monkeyID" INTEGER NOT NULL PRIMARY KEY, + "fleaCount" INTEGER +); +create sequence mixed_case_monkeys_seq minvalue 10000; + +CREATE TABLE minimalistics ( + id INTEGER NOT NULL PRIMARY KEY +); +create sequence minimalistics_seq minvalue 10000; diff --git a/activerecord/test/schema/oracle2.drop.sql b/activerecord/test/schema/oracle2.drop.sql new file mode 100644 index 0000000000..abe7e55c31 --- /dev/null +++ b/activerecord/test/schema/oracle2.drop.sql @@ -0,0 +1,2 @@ +drop table courses; +drop sequence courses_seq; diff --git a/activerecord/test/schema/oracle2.sql b/activerecord/test/schema/oracle2.sql new file mode 100644 index 0000000000..3c171f4f14 --- /dev/null +++ b/activerecord/test/schema/oracle2.sql @@ -0,0 +1,6 @@ +create table courses ( + id int not null primary key, + name varchar(255) not null +); + +create sequence courses_seq minvalue 10000; diff --git a/activerecord/test/schema/postgresql.drop.sql b/activerecord/test/schema/postgresql.drop.sql new file mode 100644 index 0000000000..31e2d38743 --- /dev/null +++ b/activerecord/test/schema/postgresql.drop.sql @@ -0,0 +1,44 @@ +DROP TABLE accounts; +DROP SEQUENCE accounts_id_seq; +DROP TABLE funny_jokes; +DROP TABLE companies; +DROP SEQUENCE companies_nonstd_seq; +DROP TABLE topics; +DROP TABLE developers; +DROP TABLE projects; +DROP TABLE developers_projects; +DROP TABLE customers; +DROP TABLE orders; +DROP TABLE movies; +DROP TABLE subscribers; +DROP TABLE booleantests; +DROP TABLE auto_id_tests; +DROP TABLE entrants; +DROP TABLE colnametests; +DROP TABLE mixins; +DROP TABLE people; +DROP TABLE readers; +DROP TABLE binaries; +DROP TABLE computers; +DROP TABLE posts; +DROP TABLE comments; +DROP TABLE authors; +DROP TABLE tasks; +DROP TABLE categories; +DROP TABLE categories_posts; +DROP TABLE defaults; +DROP TABLE fk_test_has_fk; +DROP TABLE fk_test_has_pk; +DROP TABLE geometrics; +DROP TABLE keyboards; +DROP TABLE legacy_things; +DROP TABLE numeric_data; +DROP TABLE column_data; +DROP TABLE mixed_case_monkeys; +DROP TABLE postgresql_arrays; +DROP TABLE postgresql_moneys; +DROP TABLE postgresql_numbers; +DROP TABLE postgresql_times; +DROP TABLE postgresql_network_addresses; +DROP TABLE postgresql_bit_strings; +DROP TABLE postgresql_oids; diff --git a/activerecord/test/schema/postgresql.sql b/activerecord/test/schema/postgresql.sql new file mode 100644 index 0000000000..f2198f24e9 --- /dev/null +++ b/activerecord/test/schema/postgresql.sql @@ -0,0 +1,292 @@ +CREATE SEQUENCE public.accounts_id_seq START 100; + +CREATE TABLE accounts ( + id integer primary key DEFAULT nextval('public.accounts_id_seq'), + firm_id integer, + credit_limit integer +); + +CREATE TABLE funny_jokes ( + id serial, + name character varying(50) +); + +CREATE SEQUENCE companies_nonstd_seq START 101; + +CREATE TABLE companies ( + id integer primary key DEFAULT nextval('companies_nonstd_seq'), + "type" character varying(50), + "ruby_type" character varying(50), + firm_id integer, + name character varying(50), + client_of integer, + rating integer default 1 +); + +CREATE TABLE developers_projects ( + developer_id integer NOT NULL, + project_id integer NOT NULL, + joined_on date, + access_level integer default 1 +); + +CREATE TABLE developers ( + id serial primary key, + name character varying(100), + salary integer DEFAULT 70000, + created_at timestamp, + updated_at timestamp +); +SELECT setval('developers_id_seq', 100); + +CREATE TABLE projects ( + id serial primary key, + name character varying(100), + type varchar(255) +); +SELECT setval('projects_id_seq', 100); + +CREATE TABLE topics ( + id serial primary key, + title character varying(255), + author_name character varying(255), + author_email_address character varying(255), + written_on timestamp without time zone, + bonus_time time, + last_read date, + content text, + approved boolean default true, + replies_count integer default 0, + parent_id integer, + "type" character varying(50) +); +SELECT setval('topics_id_seq', 100); + +CREATE TABLE customers ( + id serial primary key, + name character varying, + balance integer default 0, + address_street character varying, + address_city character varying, + address_country character varying, + gps_location character varying +); +SELECT setval('customers_id_seq', 100); + +CREATE TABLE orders ( + id serial primary key, + name character varying, + billing_customer_id integer, + shipping_customer_id integer +); +SELECT setval('orders_id_seq', 100); + +CREATE TABLE movies ( + movieid serial primary key, + name text +); + +CREATE TABLE subscribers ( + nick text primary key NOT NULL, + name text +); + +CREATE TABLE booleantests ( + id serial primary key, + value boolean +); + +CREATE TABLE defaults ( + id serial primary key, + modified_date date default CURRENT_DATE, + modified_date_function date default now(), + fixed_date date default '2004-01-01', + modified_time timestamp default CURRENT_TIMESTAMP, + modified_time_function timestamp default now(), + fixed_time timestamp default '2004-01-01 00:00:00.000000-00', + char1 char(1) default 'Y', + char2 character varying(50) default 'a varchar field', + char3 text default 'a text field', + positive_integer integer default 1, + negative_integer integer default -1, + decimal_number decimal(3,2) default 2.78, + multiline_default text DEFAULT E'--- []\n\n'::text +); + +CREATE TABLE auto_id_tests ( + auto_id serial primary key, + value integer +); + +CREATE TABLE entrants ( + id serial primary key, + name text not null, + course_id integer not null +); + +CREATE TABLE colnametests ( + id serial primary key, + "references" integer NOT NULL +); + +CREATE TABLE mixins ( + id serial primary key, + parent_id integer, + type character varying, + pos integer, + lft integer, + rgt integer, + root_id integer, + created_at timestamp, + updated_at timestamp +); + +CREATE TABLE people ( + id serial primary key, + first_name text, + lock_version integer default 0 +); + +CREATE TABLE readers ( + id serial primary key, + post_id integer NOT NULL, + person_id integer NOT NULL +); + +CREATE TABLE binaries ( + id serial primary key, + data bytea +); + +CREATE TABLE computers ( + id serial primary key, + developer integer NOT NULL, + "extendedWarranty" integer NOT NULL +); + +CREATE TABLE posts ( + id serial primary key, + author_id integer, + title varchar(255), + type varchar(255), + body text +); + +CREATE TABLE comments ( + id serial primary key, + post_id integer, + type varchar(255), + body text +); + +CREATE TABLE authors ( + id serial primary key, + name varchar(255) default NULL +); + +CREATE TABLE tasks ( + id serial primary key, + starting timestamp, + ending timestamp +); + +CREATE TABLE categories ( + id serial primary key, + name varchar(255), + type varchar(255) +); + +CREATE TABLE categories_posts ( + category_id integer NOT NULL, + post_id integer NOT NULL +); + +CREATE TABLE fk_test_has_pk ( + id INTEGER NOT NULL PRIMARY KEY +); + +CREATE TABLE fk_test_has_fk ( + id INTEGER NOT NULL PRIMARY KEY, + fk_id INTEGER NOT NULL REFERENCES fk_test_has_fk(id) +); + +CREATE TABLE geometrics ( + id serial primary key, + a_point point, + -- a_line line, (the line type is currently not implemented in postgresql) + a_line_segment lseg, + a_box box, + a_path path, + a_polygon polygon, + a_circle circle +); + +CREATE TABLE keyboards ( + key_number serial primary key, + "name" character varying(50) +); + +--Altered lock_version column name. +CREATE TABLE legacy_things ( + id serial primary key, + tps_report_number integer, + version integer default 0 +); + +CREATE TABLE numeric_data ( + id serial primary key, + bank_balance decimal(10,2), + big_bank_balance decimal(15,2), + world_population decimal(10), + my_house_population decimal(2), + decimal_number_with_default decimal(3,2) default 2.78 +); + +CREATE TABLE mixed_case_monkeys ( + "monkeyID" INTEGER PRIMARY KEY, + "fleaCount" INTEGER +); + +CREATE TABLE postgresql_arrays ( + id SERIAL PRIMARY KEY, + commission_by_quarter INTEGER[], + nicknames TEXT[] +); + +CREATE TABLE postgresql_moneys ( + id SERIAL PRIMARY KEY, + wealth MONEY +); + +CREATE TABLE postgresql_numbers ( + id SERIAL PRIMARY KEY, + single REAL, + double DOUBLE PRECISION +); + +CREATE TABLE postgresql_times ( + id SERIAL PRIMARY KEY, + time_interval INTERVAL +); + +CREATE TABLE postgresql_network_addresses ( + id SERIAL PRIMARY KEY, + cidr_address CIDR, + inet_address INET, + mac_address MACADDR +); + +CREATE TABLE postgresql_bit_strings ( + id SERIAL PRIMARY KEY, + bit_string BIT(8), + bit_string_varying BIT VARYING(8) +); + +CREATE TABLE postgresql_oids ( + id SERIAL PRIMARY KEY, + obj_id OID +); + +CREATE TABLE minimalistics ( + id serial primary key +); diff --git a/activerecord/test/schema/postgresql2.drop.sql b/activerecord/test/schema/postgresql2.drop.sql new file mode 100644 index 0000000000..09681bf446 --- /dev/null +++ b/activerecord/test/schema/postgresql2.drop.sql @@ -0,0 +1 @@ +DROP TABLE courses; diff --git a/activerecord/test/schema/postgresql2.sql b/activerecord/test/schema/postgresql2.sql new file mode 100644 index 0000000000..4605b9384e --- /dev/null +++ b/activerecord/test/schema/postgresql2.sql @@ -0,0 +1,4 @@ +CREATE TABLE courses ( + id serial primary key, + name text +); diff --git a/activerecord/test/schema/schema.rb b/activerecord/test/schema/schema.rb new file mode 100644 index 0000000000..2d187a601a --- /dev/null +++ b/activerecord/test/schema/schema.rb @@ -0,0 +1,358 @@ +ActiveRecord::Schema.define do + + # adapter name is checked because we are under a transition of + # moving the sql files under activerecord/test/fixtures/db_definitions + # to this file, schema.rb. + if adapter_name == "MySQL" + + # Please keep these create table statements in alphabetical order + # unless the ordering matters. In which case, define them below + create_table :accounts, :force => true do |t| + t.integer :firm_id + t.integer :credit_limit + end + + create_table :authors, :force => true do |t| + t.string :name, :null => false + end + + create_table :auto_id_tests, :force => true, :id => false do |t| + t.primary_key :auto_id + t.integer :value + end + + create_table :binaries, :force => true do |t| + t.binary :data + end + + create_table :booleantests, :force => true do |t| + t.integer :value + end + + create_table :categories, :force => true do |t| + t.string :name, :null => false + t.string :type + end + + create_table :categories_posts, :force => true, :id => false do |t| + t.integer :category_id, :null => false + t.integer :post_id, :null => false + end + + create_table :colnametests, :force => true do |t| + t.integer :references, :null => false + end + + create_table :comments, :force => true do |t| + t.integer :post_id, :null => false + t.text :body, :null => false + t.string :type + end + + create_table :companies, :force => true do |t| + t.string :type + t.string :ruby_type + t.integer :firm_id + t.string :name + t.integer :client_of + t.integer :rating, :default => 1 + end + + create_table :computers, :force => true do |t| + t.integer :developer, :null => false + t.integer :extendedWarranty, :null => false + end + + + create_table :customers, :force => true do |t| + t.string :name + t.integer :balance, :default => 0 + t.string :address_street + t.string :address_city + t.string :address_country + t.string :gps_location + end + + create_table :developers, :force => true do |t| + t.string :name + t.integer :salary, :default => 70000 + t.datetime :created_at + t.datetime :updated_at + end + + create_table :developers_projects, :force => true, :id => false do |t| + t.integer :developer_id, :null => false + t.integer :project_id, :null => false + t.date :joined_on + t.integer :access_level, :default => 1 + end + + create_table :entrants, :force => true do |t| + t.string :name, :null => false + t.integer :course_id, :null => false + end + + create_table :funny_jokes, :force => true do |t| + t.string :name + end + + create_table :keyboards, :force => true, :id => false do |t| + t.primary_key :key_number + t.string :name + end + + create_table :legacy_things, :force => true do |t| + t.integer :tps_report_number + t.integer :version, :null => false, :default => 0 + end + + create_table :minimalistics, :force => true do |t| + end + + create_table :mixed_case_monkeys, :force => true, :id => false do |t| + t.primary_key :monkeyID + t.integer :fleaCount + end + + create_table :mixins, :force => true do |t| + t.integer :parent_id + t.integer :pos + t.datetime :created_at + t.datetime :updated_at + t.integer :lft + t.integer :rgt + t.integer :root_id + t.string :type + end + + create_table :movies, :force => true, :id => false do |t| + t.primary_key :movieid + t.string :name + end + + create_table :numeric_data, :force => true do |t| + t.decimal :bank_balance, :precision => 10, :scale => 2 + t.decimal :big_bank_balance, :precision => 15, :scale => 2 + t.decimal :world_population, :precision => 10, :scale => 0 + t.decimal :my_house_population, :precision => 2, :scale => 0 + t.decimal :decimal_number_with_default, :precision => 3, :scale => 2, :default => 2.78 + end + + create_table :orders, :force => true do |t| + t.string :name + t.integer :billing_customer_id + t.integer :shipping_customer_id + end + + create_table :people, :force => true do |t| + t.string :first_name, :null => false + t.integer :lock_version, :null => false, :default => 0 + end + + create_table :posts, :force => true do |t| + t.integer :author_id + t.string :title, :null => false + t.text :body, :null => false + t.string :type + end + + create_table :projects, :force => true do |t| + t.string :name + t.string :type + end + + create_table :readers, :force => true do |t| + t.integer :post_id, :null => false + t.integer :person_id, :null => false + end + + create_table :subscribers, :force => true, :id => false do |t| + t.string :nick, :null => false + t.string :name + end + add_index :subscribers, :nick, :unique => true + + create_table :tasks, :force => true do |t| + t.datetime :starting + t.datetime :ending + end + + create_table :topics, :force => true do |t| + t.string :title + t.string :author_name + t.string :author_email_address + t.datetime :written_on + t.time :bonus_time + t.date :last_read + t.text :content + t.boolean :approved, :default => true + t.integer :replies_count, :default => 0 + t.integer :parent_id + t.string :type + end + + + + ### These tables are created last as the order is significant + + # fk_test_has_fk should be before fk_test_has_pk + create_table :fk_test_has_fk, :force => true do |t| + t.integer :fk_id, :null => false + end + + create_table :fk_test_has_pk, :force => true do |t| + end + + execute 'alter table fk_test_has_fk + add FOREIGN KEY (`fk_id`) REFERENCES `fk_test_has_pk`(`id`)' + + + end + + # 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 + t.column :taggable_type, :string + t.column :taggable_id, :integer + end + + create_table :tags, :force => true do |t| + t.column :name, :string + t.column :taggings_count, :integer, :default => 0 + end + + create_table :categorizations, :force => true do |t| + t.column :category_id, :integer + t.column :post_id, :integer + t.column :author_id, :integer + end + + add_column :posts, :taggings_count, :integer, :default => 0 + add_column :authors, :author_address_id, :integer + + create_table :author_addresses, :force => true do |t| + t.column :author_address_id, :integer + end + + create_table :author_favorites, :force => true do |t| + t.column :author_id, :integer + t.column :favorite_author_id, :integer + end + + create_table :vertices, :force => true do |t| + t.column :label, :string + end + + create_table :edges, :force => true do |t| + t.column :source_id, :integer, :null => false + t.column :sink_id, :integer, :null => false + end + add_index :edges, [:source_id, :sink_id], :unique => true, :name => 'unique_edge_index' + + create_table :lock_without_defaults, :force => true do |t| + t.column :lock_version, :integer + end + + create_table :lock_without_defaults_cust, :force => true do |t| + t.column :custom_lock_version, :integer + end + + create_table :items, :force => true do |t| + t.column :name, :integer + end + + # For sqlite 3.1.0+, make a table with a autoincrement column + if adapter_name == 'SQLite' and supports_autoincrement? + create_table :table_with_autoincrement, :force => true do |t| + t.column :name, :string + end + end + + # For sqlserver 2000+, ensure real columns can be used + if adapter_name.starts_with?("SQLServer") + create_table :table_with_real_columns, :force => true do |t| + t.column :real_number, :real + end + end + + create_table :audit_logs, :force => true do |t| + t.column :message, :string, :null=>false + t.column :developer_id, :integer, :null=>false + end + + create_table :books, :force => true do |t| + t.column :name, :string + end + + create_table :citations, :force => true do |t| + t.column :book1_id, :integer + t.column :book2_id, :integer + end + + create_table :inept_wizards, :force => true do |t| + t.column :name, :string, :null => false + t.column :city, :string, :null => false + t.column :type, :string + end + + create_table :parrots, :force => true do |t| + t.column :name, :string + t.column :parrot_sti_class, :string + t.column :killer_id, :integer + t.column :created_at, :datetime + t.column :created_on, :datetime + t.column :updated_at, :datetime + t.column :updated_on, :datetime + end + + create_table :pirates, :force => true do |t| + t.column :catchphrase, :string + t.column :parrot_id, :integer + t.column :created_on, :datetime + t.column :updated_on, :datetime + end + + create_table :parrots_pirates, :id => false, :force => true do |t| + t.column :parrot_id, :integer + t.column :pirate_id, :integer + end + + create_table :treasures, :force => true do |t| + t.column :name, :string + t.column :looter_id, :integer + t.column :looter_type, :string + end + + create_table :parrots_treasures, :id => false, :force => true do |t| + t.column :parrot_id, :integer + t.column :treasure_id, :integer + end + + create_table :mateys, :id => false, :force => true do |t| + t.column :pirate_id, :integer + t.column :target_id, :integer + t.column :weight, :integer + end + + create_table :ships, :force => true do |t| + t.string :name + t.datetime :created_at + t.datetime :created_on + t.datetime :updated_at + t.datetime :updated_on + end + + create_table 'warehouse-things', :force => true do |t| + t.integer :value + end +end diff --git a/activerecord/test/schema/schema2.rb b/activerecord/test/schema/schema2.rb new file mode 100644 index 0000000000..863237d271 --- /dev/null +++ b/activerecord/test/schema/schema2.rb @@ -0,0 +1,11 @@ +ActiveRecord::Schema.define do + + # adapter name is checked because we are under a transition of + # moving the sql files under activerecord/test/fixtures/db_definitions + # to this file, schema.rb. + if adapter_name == "MySQL" + Course.connection.create_table :courses, :force => true do |t| + t.column :name, :string, :null => false + end + end +end diff --git a/activerecord/test/schema/sqlite.drop.sql b/activerecord/test/schema/sqlite.drop.sql new file mode 100644 index 0000000000..419cdaa52c --- /dev/null +++ b/activerecord/test/schema/sqlite.drop.sql @@ -0,0 +1,33 @@ +DROP TABLE accounts; +DROP TABLE funny_jokes; +DROP TABLE companies; +DROP TABLE topics; +DROP TABLE developers; +DROP TABLE projects; +DROP TABLE developers_projects; +DROP TABLE customers; +DROP TABLE orders; +DROP TABLE movies; +DROP TABLE subscribers; +DROP TABLE booleantests; +DROP TABLE auto_id_tests; +DROP TABLE entrants; +DROP TABLE colnametests; +DROP TABLE mixins; +DROP TABLE people; +DROP TABLE readers; +DROP TABLE binaries; +DROP TABLE computers; +DROP TABLE tasks; +DROP TABLE posts; +DROP TABLE comments; +DROP TABLE authors; +DROP TABLE categories; +DROP TABLE categories_posts; +DROP TABLE fk_test_has_fk; +DROP TABLE fk_test_has_pk; +DROP TABLE keyboards; +DROP TABLE legacy_things; +DROP TABLE numeric_data; +DROP TABLE mixed_case_monkeys; +DROP TABLE minimalistics; diff --git a/activerecord/test/schema/sqlite.sql b/activerecord/test/schema/sqlite.sql new file mode 100644 index 0000000000..27966790b8 --- /dev/null +++ b/activerecord/test/schema/sqlite.sql @@ -0,0 +1,219 @@ +CREATE TABLE 'accounts' ( + 'id' INTEGER PRIMARY KEY NOT NULL, + 'firm_id' INTEGER DEFAULT NULL, + 'credit_limit' INTEGER DEFAULT NULL +); + +CREATE TABLE 'funny_jokes' ( + 'id' INTEGER PRIMARY KEY NOT NULL, + 'name' TEXT DEFAULT NULL +); + +CREATE TABLE 'companies' ( + 'id' INTEGER PRIMARY KEY NOT NULL, + 'type' VARCHAR(255) DEFAULT NULL, + 'ruby_type' VARCHAR(255) DEFAULT NULL, + 'firm_id' INTEGER DEFAULT NULL, + 'name' TEXT DEFAULT NULL, + 'client_of' INTEGER DEFAULT NULL, + 'rating' INTEGER DEFAULT 1 +); + + +CREATE TABLE 'topics' ( + 'id' INTEGER PRIMARY KEY NOT NULL, + 'title' VARCHAR(255) DEFAULT NULL, + 'author_name' VARCHAR(255) DEFAULT NULL, + 'author_email_address' VARCHAR(255) DEFAULT NULL, + 'written_on' DATETIME DEFAULT NULL, + 'bonus_time' TIME DEFAULT NULL, + 'last_read' DATE DEFAULT NULL, + 'content' TEXT, + 'approved' boolean DEFAULT 't', + 'replies_count' INTEGER DEFAULT 0, + 'parent_id' INTEGER DEFAULT NULL, + 'type' VARCHAR(255) DEFAULT NULL +); + +CREATE TABLE 'developers' ( + 'id' INTEGER PRIMARY KEY NOT NULL, + 'name' TEXT DEFAULT NULL, + 'salary' INTEGER DEFAULT 70000, + 'created_at' DATETIME DEFAULT NULL, + 'updated_at' DATETIME DEFAULT NULL +); + +CREATE TABLE 'projects' ( + 'id' INTEGER PRIMARY KEY NOT NULL, + 'name' TEXT DEFAULT NULL, + 'type' VARCHAR(255) DEFAULT NULL +); + +CREATE TABLE 'developers_projects' ( + 'developer_id' INTEGER NOT NULL, + 'project_id' INTEGER NOT NULL, + 'joined_on' DATE DEFAULT NULL, + 'access_level' INTEGER DEFAULT 1 +); + + +CREATE TABLE 'orders' ( + 'id' INTEGER PRIMARY KEY NOT NULL, + 'name' VARCHAR(255) DEFAULT NULL, + 'billing_customer_id' INTEGER DEFAULT NULL, + 'shipping_customer_id' INTEGER DEFAULT NULL +); + +CREATE TABLE 'customers' ( + 'id' INTEGER PRIMARY KEY NOT NULL, + 'name' VARCHAR(255) DEFAULT NULL, + 'balance' INTEGER DEFAULT 0, + 'address_street' TEXT DEFAULT NULL, + 'address_city' TEXT DEFAULT NULL, + 'address_country' TEXT DEFAULT NULL, + 'gps_location' TEXT DEFAULT NULL +); + +CREATE TABLE 'movies' ( + 'movieid' INTEGER PRIMARY KEY NOT NULL, + 'name' VARCHAR(255) DEFAULT NULL +); + +CREATE TABLE subscribers ( + 'nick' VARCHAR(255) PRIMARY KEY NOT NULL, + 'name' VARCHAR(255) DEFAULT NULL +); + +CREATE TABLE 'booleantests' ( + 'id' INTEGER PRIMARY KEY NOT NULL, + 'value' INTEGER DEFAULT NULL +); + +CREATE TABLE 'auto_id_tests' ( + 'auto_id' INTEGER PRIMARY KEY NOT NULL, + 'value' INTEGER DEFAULT NULL +); + +CREATE TABLE 'entrants' ( + 'id' INTEGER NOT NULL PRIMARY KEY, + 'name' VARCHAR(255) NOT NULL, + 'course_id' INTEGER NOT NULL +); + +CREATE TABLE 'colnametests' ( + 'id' INTEGER NOT NULL PRIMARY KEY, + 'references' INTEGER NOT NULL +); + +CREATE TABLE 'mixins' ( + 'id' INTEGER NOT NULL PRIMARY KEY, + 'parent_id' INTEGER DEFAULT NULL, + 'type' VARCHAR(40) DEFAULT NULL, + 'pos' INTEGER DEFAULT NULL, + 'lft' INTEGER DEFAULT NULL, + 'rgt' INTEGER DEFAULT NULL, + 'root_id' INTEGER DEFAULT NULL, + 'created_at' DATETIME DEFAULT NULL, + 'updated_at' DATETIME DEFAULT NULL +); + +CREATE TABLE 'people' ( + 'id' INTEGER NOT NULL PRIMARY KEY, + 'first_name' VARCHAR(40) DEFAULT NULL, + 'lock_version' INTEGER NOT NULL DEFAULT 0 +); + +CREATE TABLE 'readers' ( + 'id' INTEGER NOT NULL PRIMARY KEY, + 'post_id' INTEGER NOT NULL, + 'person_id' INTEGER NOT NULL +); + +CREATE TABLE 'binaries' ( + 'id' INTEGER NOT NULL PRIMARY KEY, + 'data' BLOB DEFAULT NULL +); + +CREATE TABLE 'computers' ( + 'id' INTEGER NOT NULL PRIMARY KEY, + 'developer' INTEGER NOT NULL, + 'extendedWarranty' INTEGER NOT NULL +); + +CREATE TABLE 'posts' ( + 'id' INTEGER NOT NULL PRIMARY KEY, + 'author_id' INTEGER, + 'title' VARCHAR(255) NOT NULL, + 'type' VARCHAR(255) DEFAULT NULL, + 'body' TEXT NOT NULL +); + +CREATE TABLE 'comments' ( + 'id' INTEGER NOT NULL PRIMARY KEY, + 'post_id' INTEGER NOT NULL, + 'type' VARCHAR(255) DEFAULT NULL, + 'body' TEXT NOT NULL +); + +CREATE TABLE 'authors' ( + 'id' INTEGER NOT NULL PRIMARY KEY, + 'name' VARCHAR(255) NOT NULL +); + +CREATE TABLE 'tasks' ( + 'id' INTEGER NOT NULL PRIMARY KEY, + 'starting' DATETIME DEFAULT NULL, + 'ending' DATETIME DEFAULT NULL +); + +CREATE TABLE 'categories' ( + 'id' INTEGER NOT NULL PRIMARY KEY, + 'name' VARCHAR(255) NOT NULL, + 'type' VARCHAR(255) DEFAULT NULL +); + +CREATE TABLE 'categories_posts' ( + 'category_id' INTEGER NOT NULL, + 'post_id' INTEGER NOT NULL +); + +CREATE TABLE 'fk_test_has_pk' ( + 'id' INTEGER NOT NULL PRIMARY KEY +); + +CREATE TABLE 'fk_test_has_fk' ( + 'id' INTEGER NOT NULL PRIMARY KEY, + 'fk_id' INTEGER NOT NULL, + + FOREIGN KEY ('fk_id') REFERENCES 'fk_test_has_pk'('id') +); + +CREATE TABLE 'keyboards' ( + 'key_number' INTEGER PRIMARY KEY NOT NULL, + 'name' VARCHAR(255) DEFAULT NULL +); + +--Altered lock_version column name. +CREATE TABLE 'legacy_things' ( + 'id' INTEGER NOT NULL PRIMARY KEY, + 'tps_report_number' INTEGER DEFAULT NULL, + 'version' INTEGER NOT NULL DEFAULT 0 +); + +CREATE TABLE 'numeric_data' ( + 'id' INTEGER NOT NULL PRIMARY KEY, + 'bank_balance' DECIMAL(10,2), + 'big_bank_balance' DECIMAL(15,2), + 'world_population' DECIMAL(10), + 'my_house_population' DECIMAL(2), + 'decimal_number_with_default' DECIMAL(3,2) DEFAULT 2.78 +); + +CREATE TABLE mixed_case_monkeys ( + 'monkeyID' INTEGER NOT NULL PRIMARY KEY, + 'fleaCount' INTEGER +); + +CREATE TABLE minimalistics ( + 'id' INTEGER NOT NULL PRIMARY KEY +); diff --git a/activerecord/test/schema/sqlite2.drop.sql b/activerecord/test/schema/sqlite2.drop.sql new file mode 100644 index 0000000000..09681bf446 --- /dev/null +++ b/activerecord/test/schema/sqlite2.drop.sql @@ -0,0 +1 @@ +DROP TABLE courses; diff --git a/activerecord/test/schema/sqlite2.sql b/activerecord/test/schema/sqlite2.sql new file mode 100644 index 0000000000..19b123968a --- /dev/null +++ b/activerecord/test/schema/sqlite2.sql @@ -0,0 +1,4 @@ +CREATE TABLE 'courses' ( + 'id' INTEGER NOT NULL PRIMARY KEY, + 'name' VARCHAR(255) NOT NULL +); diff --git a/activerecord/test/schema/sybase.drop.sql b/activerecord/test/schema/sybase.drop.sql new file mode 100644 index 0000000000..ebb91931fb --- /dev/null +++ b/activerecord/test/schema/sybase.drop.sql @@ -0,0 +1,35 @@ +DROP TABLE accounts +DROP TABLE funny_jokes +DROP TABLE companies +DROP TABLE topics +DROP TABLE developers +DROP TABLE projects +DROP TABLE developers_projects +DROP TABLE customers +DROP TABLE orders +DROP TABLE movies +DROP TABLE subscribers +DROP TABLE booleantests +DROP TABLE auto_id_tests +DROP TABLE entrants +DROP TABLE colnametests +DROP TABLE mixins +DROP TABLE people +DROP TABLE readers +DROP TABLE binaries +DROP TABLE computers +DROP TABLE tasks +DROP TABLE posts +DROP TABLE comments +DROP TABLE authors +DROP TABLE categories +DROP TABLE categories_posts +DROP TABLE fk_test_has_fk +DROP TABLE fk_test_has_pk +DROP TABLE keyboards +DROP TABLE legacy_things +DROP TABLE numeric_data +DROP TABLE mixed_case_monkeys +DROP TABLE minimalistics +DROP TABLE schema_info +go diff --git a/activerecord/test/schema/sybase.sql b/activerecord/test/schema/sybase.sql new file mode 100644 index 0000000000..9f0cb3ebe2 --- /dev/null +++ b/activerecord/test/schema/sybase.sql @@ -0,0 +1,222 @@ +CREATE TABLE accounts ( + id numeric(9,0) IDENTITY PRIMARY KEY, + firm_id int NULL, + credit_limit int NULL +) + +CREATE TABLE funny_jokes ( +id numeric(9,0) IDENTITY PRIMARY KEY, + name varchar(50) NULL +) + +CREATE TABLE companies ( + id numeric(9,0) IDENTITY PRIMARY KEY, + type varchar(50) NULL, + ruby_type varchar(50) NULL, + firm_id int NULL, + name varchar(50) NULL, + client_of int NULL, + rating int default 1 +) + + +CREATE TABLE topics ( + id numeric(9,0) IDENTITY PRIMARY KEY, + title varchar(255) NULL, + author_name varchar(255) NULL, + author_email_address varchar(255) NULL, + written_on datetime NULL, + bonus_time datetime NULL, + last_read datetime NULL, + content varchar(255) NULL, + approved bit default 1, + replies_count int default 0, + parent_id int NULL, + type varchar(50) NULL +) + +CREATE TABLE developers ( + id numeric(9,0) IDENTITY PRIMARY KEY, + name varchar(100) NULL, + salary int default 70000, + created_at datetime NULL, + updated_at datetime NULL +) + +CREATE TABLE projects ( + id numeric(9,0) IDENTITY PRIMARY KEY, + name varchar(100) NULL, + type varchar(255) NULL +) + +CREATE TABLE developers_projects ( + developer_id int NOT NULL, + project_id int NOT NULL, + joined_on datetime NULL, + access_level smallint default 1 +) + +CREATE TABLE orders ( + id numeric(9,0) IDENTITY PRIMARY KEY, + name varchar(100) NULL, + billing_customer_id int NULL, + shipping_customer_id int NULL +) + +CREATE TABLE customers ( + id numeric(9,0) IDENTITY PRIMARY KEY, + name varchar(100) NULL, + balance int default 0, + address_street varchar(100) NULL, + address_city varchar(100) NULL, + address_country varchar(100) NULL, + gps_location varchar(100) NULL +) + +CREATE TABLE movies ( + movieid numeric(9,0) IDENTITY PRIMARY KEY, + name varchar(100) NULL +) + +CREATE TABLE subscribers ( + nick varchar(100) PRIMARY KEY, + name varchar(100) NULL +) + +CREATE TABLE booleantests ( + id numeric(9,0) IDENTITY PRIMARY KEY, + value int NULL +) + +CREATE TABLE auto_id_tests ( + auto_id numeric(9,0) IDENTITY PRIMARY KEY, + value int NULL +) + +CREATE TABLE entrants ( + id numeric(9,0) IDENTITY PRIMARY KEY, + name varchar(255) NOT NULL, + course_id int NOT NULL +) + +CREATE TABLE colnametests ( + id numeric(9,0) IDENTITY PRIMARY KEY, + [references] int NOT NULL +) + +CREATE TABLE mixins ( + id numeric(9,0) IDENTITY PRIMARY KEY, + parent_id int NULL, + pos int NULL, + created_at datetime NULL, + updated_at datetime NULL, + lft int NULL, + rgt int NULL, + root_id int NULL, + type varchar(40) NULL +) + +CREATE TABLE people ( + id numeric(9,0) IDENTITY PRIMARY KEY, + first_name varchar(40) NULL, + lock_version int DEFAULT 0 +) + +CREATE TABLE readers ( + id numeric(9,0) IDENTITY PRIMARY KEY, + post_id int NOT NULL, + person_id int NOT NULL +) + +CREATE TABLE binaries ( + id numeric(9,0) IDENTITY PRIMARY KEY, + data image NULL +) + +CREATE TABLE computers ( + id numeric(9,0) IDENTITY PRIMARY KEY, + developer int NOT NULL, + extendedWarranty int NOT NULL +) + +CREATE TABLE posts ( + id numeric(9,0) IDENTITY PRIMARY KEY, + author_id int NULL, + title varchar(255) NOT NULL, + body varchar(2048) NOT NULL, + type varchar(255) NOT NULL +) + +CREATE TABLE comments ( + id numeric(9,0) IDENTITY PRIMARY KEY, + post_id int NOT NULL, + body varchar(2048) NOT NULL, + type varchar(255) NOT NULL +) + +CREATE TABLE authors ( + id numeric(9,0) IDENTITY PRIMARY KEY, + name varchar(255) NOT NULL +) + +CREATE TABLE tasks ( + id numeric(9,0) IDENTITY PRIMARY KEY, + starting datetime NULL, + ending datetime NULL +) + +CREATE TABLE categories ( + id numeric(9,0) IDENTITY PRIMARY KEY, + name varchar(255) NOT NULL, + type varchar(255) NOT NULL +) + +CREATE TABLE categories_posts ( + category_id int NOT NULL, + post_id int NOT NULL +) + +CREATE TABLE fk_test_has_pk ( + id numeric(9,0) IDENTITY PRIMARY KEY +) + +CREATE TABLE fk_test_has_fk ( + id numeric(9,0) PRIMARY KEY, + fk_id numeric(9,0) NOT NULL, + + FOREIGN KEY (fk_id) REFERENCES fk_test_has_pk(id) +) + + +CREATE TABLE keyboards ( + key_number numeric(9,0) IDENTITY PRIMARY KEY, + name varchar(50) NULL +) + +--This table has an altered lock_version column name. +CREATE TABLE legacy_things ( + id numeric(9,0) IDENTITY PRIMARY KEY, + tps_report_number int default NULL, + version int default 0 +) + + +CREATE TABLE numeric_data ( + id numeric(9,0) IDENTITY PRIMARY KEY, + bank_balance numeric(10,2), + big_bank_balance numeric(15,2), + world_population numeric(10), + my_house_population numeric(2), + decimal_number_with_default numeric(3,2) DEFAULT 2.78 +) + +CREATE TABLE mixed_case_monkeys ( + [monkeyID] numeric(9,0) IDENTITY PRIMARY KEY, + [fleaCount] numeric(9,0) +); + +CREATE TABLE minimalistics ( + id numeric(9,0) IDENTITY PRIMARY KEY +); + +go diff --git a/activerecord/test/schema/sybase2.drop.sql b/activerecord/test/schema/sybase2.drop.sql new file mode 100644 index 0000000000..ea1571da0b --- /dev/null +++ b/activerecord/test/schema/sybase2.drop.sql @@ -0,0 +1,2 @@ +DROP TABLE courses +go diff --git a/activerecord/test/schema/sybase2.sql b/activerecord/test/schema/sybase2.sql new file mode 100644 index 0000000000..88f9d329a3 --- /dev/null +++ b/activerecord/test/schema/sybase2.sql @@ -0,0 +1,5 @@ +CREATE TABLE courses ( + id int NOT NULL PRIMARY KEY, + name varchar(255) NOT NULL +) +go -- cgit v1.2.3