ibm_db 0.9.5 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +5 -0
- data/README +63 -97
- data/ext/ibm_db.c +20 -4
- data/ext/ruby_ibm_db.h +10 -0
- data/lib/active_record/connection_adapters/ibm_db_adapter.rb +2 -4
- data/test/{adapter_test.rb → cases/adapter_test.rb} +39 -14
- data/test/cases/associations/cascaded_eager_loading_test.rb +113 -0
- data/test/{associations → cases/associations}/eager_test.rb +231 -65
- data/test/cases/associations/has_and_belongs_to_many_associations_test.rb +686 -0
- data/test/cases/associations/join_model_test.rb +797 -0
- data/test/{base_test.rb → cases/base_test.rb} +605 -385
- data/test/cases/calculations_test.rb +275 -0
- data/test/cases/finder_test.rb +885 -0
- data/test/cases/fixtures_test.rb +630 -0
- data/test/{migration_test.rb → cases/migration_test.rb} +530 -146
- data/test/cases/query_cache_test.rb +127 -0
- data/test/cases/validations_test.rb +1509 -0
- data/test/connections/native_ibm_db/connection.rb +1 -1
- data/test/models/warehouse_thing.rb +5 -0
- data/test/schema/i5/ibm_db_specific_schema.rb +133 -0
- data/test/schema/ids/ibm_db_specific_schema.rb +136 -0
- data/test/schema/luw/ibm_db_specific_schema.rb +133 -0
- data/test/schema/schema.rb +432 -0
- data/test/schema/zOS/ibm_db_specific_schema.rb +204 -0
- metadata +29 -33
- data/test/associations_test.rb +0 -2151
- data/test/fixtures/db_definitions/i5/ibm_db.drop.sql +0 -33
- data/test/fixtures/db_definitions/i5/ibm_db.sql +0 -236
- data/test/fixtures/db_definitions/i5/ibm_db2.drop.sql +0 -2
- data/test/fixtures/db_definitions/i5/ibm_db2.sql +0 -5
- data/test/fixtures/db_definitions/ids/ibm_db.drop.sql +0 -33
- data/test/fixtures/db_definitions/ids/ibm_db.sql +0 -237
- data/test/fixtures/db_definitions/ids/ibm_db2.drop.sql +0 -2
- data/test/fixtures/db_definitions/ids/ibm_db2.sql +0 -5
- data/test/fixtures/db_definitions/luw/ibm_db.drop.sql +0 -33
- data/test/fixtures/db_definitions/luw/ibm_db.sql +0 -236
- data/test/fixtures/db_definitions/luw/ibm_db2.drop.sql +0 -2
- data/test/fixtures/db_definitions/luw/ibm_db2.sql +0 -5
- data/test/fixtures/db_definitions/schema.rb +0 -361
- data/test/fixtures/db_definitions/zOS/ibm_db.drop.sql +0 -33
- data/test/fixtures/db_definitions/zOS/ibm_db.sql +0 -288
- data/test/fixtures/db_definitions/zOS/ibm_db2.drop.sql +0 -2
- data/test/fixtures/db_definitions/zOS/ibm_db2.sql +0 -7
- data/test/locking_test.rb +0 -282
@@ -0,0 +1,133 @@
|
|
1
|
+
ActiveRecord::Schema.define do
|
2
|
+
|
3
|
+
execute "DROP TABLE COMMENTS" rescue nil
|
4
|
+
execute "DROP TABLE POSTS" rescue nil
|
5
|
+
execute "DROP TABLE ITEMS" rescue nil
|
6
|
+
execute "DROP TABLE TOPICS" rescue nil
|
7
|
+
execute "DROP TABLE fk_test_has_fk" rescue nil
|
8
|
+
execute "DROP TABLE fk_test_has_pk" rescue nil
|
9
|
+
execute "DROP TABLE CIRCLES" rescue nil
|
10
|
+
execute "DROP TABLE SQUARES" rescue nil
|
11
|
+
execute "DROP TABLE TRIANGLES" rescue nil
|
12
|
+
execute "DROP TABLE NON_POLY_ONES" rescue nil
|
13
|
+
execute "DROP TABLE NON_POLY_TWOS" rescue nil
|
14
|
+
execute "DROP TABLE PAINT_COLORS" rescue nil
|
15
|
+
execute "DROP TABLE PAINT_TEXTURES" rescue nil
|
16
|
+
|
17
|
+
execute <<_SQL
|
18
|
+
CREATE TABLE comments (
|
19
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 100),
|
20
|
+
post_id INT NOT NULL,
|
21
|
+
type VARCHAR(255) DEFAULT NULL,
|
22
|
+
body VARCHAR(3000)NOT NULL,
|
23
|
+
PRIMARY KEY (id)
|
24
|
+
);
|
25
|
+
_SQL
|
26
|
+
|
27
|
+
execute <<_SQL
|
28
|
+
CREATE TABLE posts (
|
29
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 100),
|
30
|
+
author_id INT DEFAULT NULL,
|
31
|
+
title VARCHAR(255) NOT NULL,
|
32
|
+
type VARCHAR(255) DEFAULT NULL,
|
33
|
+
body VARCHAR(3000) NOT NULL,
|
34
|
+
comments_count integer DEFAULT 0,
|
35
|
+
taggings_count integer DEFAULT 0,
|
36
|
+
PRIMARY KEY (id)
|
37
|
+
);
|
38
|
+
_SQL
|
39
|
+
|
40
|
+
execute <<_SQL
|
41
|
+
CREATE TABLE fk_test_has_pk (
|
42
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 100),
|
43
|
+
PRIMARY KEY (id)
|
44
|
+
);
|
45
|
+
_SQL
|
46
|
+
|
47
|
+
execute <<_SQL
|
48
|
+
CREATE TABLE fk_test_has_fk (
|
49
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 100),
|
50
|
+
fk_id integer NOT NULL,
|
51
|
+
PRIMARY KEY (id),
|
52
|
+
FOREIGN KEY (fk_id) REFERENCES fk_test_has_pk(id)
|
53
|
+
);
|
54
|
+
_SQL
|
55
|
+
|
56
|
+
execute <<_SQL
|
57
|
+
CREATE TABLE items (
|
58
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 100),
|
59
|
+
name VARCHAR(255) DEFAULT NULL,
|
60
|
+
PRIMARY KEY (id)
|
61
|
+
);
|
62
|
+
_SQL
|
63
|
+
|
64
|
+
execute <<_SQL
|
65
|
+
CREATE TABLE circles (
|
66
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 1),
|
67
|
+
PRIMARY KEY (id)
|
68
|
+
);
|
69
|
+
_SQL
|
70
|
+
|
71
|
+
execute <<_SQL
|
72
|
+
CREATE TABLE squares(
|
73
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 1),
|
74
|
+
PRIMARY KEY (id)
|
75
|
+
);
|
76
|
+
_SQL
|
77
|
+
|
78
|
+
execute <<_SQL
|
79
|
+
CREATE TABLE triangles(
|
80
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 1),
|
81
|
+
PRIMARY KEY (id)
|
82
|
+
);
|
83
|
+
_SQL
|
84
|
+
|
85
|
+
execute <<_SQL
|
86
|
+
CREATE TABLE non_poly_ones(
|
87
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 1),
|
88
|
+
PRIMARY KEY (id)
|
89
|
+
);
|
90
|
+
_SQL
|
91
|
+
|
92
|
+
execute <<_SQL
|
93
|
+
CREATE TABLE non_poly_twos(
|
94
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 1),
|
95
|
+
PRIMARY KEY (id)
|
96
|
+
);
|
97
|
+
_SQL
|
98
|
+
|
99
|
+
execute <<_SQL
|
100
|
+
CREATE TABLE paint_colors(
|
101
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 1),
|
102
|
+
non_poly_one_id INT,
|
103
|
+
PRIMARY KEY (id)
|
104
|
+
);
|
105
|
+
_SQL
|
106
|
+
|
107
|
+
execute <<_SQL
|
108
|
+
CREATE TABLE paint_textures(
|
109
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 1),
|
110
|
+
non_poly_two_id INT,
|
111
|
+
PRIMARY KEY (id)
|
112
|
+
);
|
113
|
+
_SQL
|
114
|
+
|
115
|
+
execute <<_SQL
|
116
|
+
CREATE TABLE topics (
|
117
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 100),
|
118
|
+
title VARCHAR(255) DEFAULT NULL,
|
119
|
+
author_name VARCHAR(255) DEFAULT NULL,
|
120
|
+
author_email_address VARCHAR(255) DEFAULT NULL,
|
121
|
+
written_on TIMESTAMP DEFAULT NULL,
|
122
|
+
bonus_time TIME DEFAULT NULL,
|
123
|
+
last_read DATE DEFAULT NULL,
|
124
|
+
content VARCHAR(3000),
|
125
|
+
approved SMALLINT DEFAULT 1,
|
126
|
+
replies_count INT DEFAULT 0,
|
127
|
+
parent_id INT DEFAULT NULL,
|
128
|
+
type VARCHAR(255) DEFAULT NULL,
|
129
|
+
PRIMARY KEY (id)
|
130
|
+
);
|
131
|
+
_SQL
|
132
|
+
|
133
|
+
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
ActiveRecord::Schema.define do
|
2
|
+
|
3
|
+
execute "DROP TABLE COMMENTS" rescue nil
|
4
|
+
execute "DROP TABLE POSTS" rescue nil
|
5
|
+
execute "DROP TABLE ITEMS" rescue nil
|
6
|
+
execute "DROP TABLE TOPICS" rescue nil
|
7
|
+
execute "DROP TABLE fk_test_has_fk" rescue nil
|
8
|
+
execute "DROP TABLE fk_test_has_pk" rescue nil
|
9
|
+
execute "DROP TABLE CIRCLES" rescue nil
|
10
|
+
execute "DROP TABLE SQUARES" rescue nil
|
11
|
+
execute "DROP TABLE TRIANGLES" rescue nil
|
12
|
+
execute "DROP TABLE NON_POLY_ONES" rescue nil
|
13
|
+
execute "DROP TABLE NON_POLY_TWOS" rescue nil
|
14
|
+
execute "DROP TABLE PAINT_COLORS" rescue nil
|
15
|
+
execute "DROP TABLE PAINT_TEXTURES" rescue nil
|
16
|
+
|
17
|
+
execute <<_SQL
|
18
|
+
CREATE TABLE comments (
|
19
|
+
id SERIAL(100),
|
20
|
+
post_id INT DEFAULT NULL,
|
21
|
+
type VARCHAR(255) DEFAULT NULL,
|
22
|
+
body LVARCHAR(3000) DEFAULT NULL
|
23
|
+
);
|
24
|
+
_SQL
|
25
|
+
|
26
|
+
execute <<_SQL
|
27
|
+
CREATE TABLE posts (
|
28
|
+
id SERIAL(100),
|
29
|
+
author_id INT DEFAULT NULL,
|
30
|
+
title VARCHAR(255) DEFAULT NULL,
|
31
|
+
type VARCHAR(255) DEFAULT NULL,
|
32
|
+
body LVARCHAR(3000) DEFAULT NULL,
|
33
|
+
comments_count INT DEFAULT 0,
|
34
|
+
taggings_count INT DEFAULT 0,
|
35
|
+
PRIMARY KEY (id)
|
36
|
+
);
|
37
|
+
|
38
|
+
_SQL
|
39
|
+
|
40
|
+
execute <<_SQL
|
41
|
+
CREATE TABLE items (
|
42
|
+
id SERIAL(100),
|
43
|
+
name VARCHAR(255) DEFAULT NULL,
|
44
|
+
PRIMARY KEY (id)
|
45
|
+
);
|
46
|
+
|
47
|
+
_SQL
|
48
|
+
|
49
|
+
execute <<_SQL
|
50
|
+
CREATE TABLE circles (
|
51
|
+
id SERIAL(100),
|
52
|
+
PRIMARY KEY (id)
|
53
|
+
);
|
54
|
+
_SQL
|
55
|
+
|
56
|
+
execute <<_SQL
|
57
|
+
CREATE TABLE squares(
|
58
|
+
id SERIAL(100),
|
59
|
+
PRIMARY KEY (id)
|
60
|
+
);
|
61
|
+
_SQL
|
62
|
+
|
63
|
+
execute <<_SQL
|
64
|
+
CREATE TABLE triangles(
|
65
|
+
id SERIAL(100),
|
66
|
+
PRIMARY KEY (id)
|
67
|
+
);
|
68
|
+
_SQL
|
69
|
+
|
70
|
+
execute <<_SQL
|
71
|
+
CREATE TABLE non_poly_ones(
|
72
|
+
id SERIAL(100),
|
73
|
+
PRIMARY KEY (id)
|
74
|
+
);
|
75
|
+
_SQL
|
76
|
+
|
77
|
+
execute <<_SQL
|
78
|
+
CREATE TABLE non_poly_twos(
|
79
|
+
id SERIAL(100),
|
80
|
+
PRIMARY KEY (id)
|
81
|
+
);
|
82
|
+
_SQL
|
83
|
+
|
84
|
+
execute <<_SQL
|
85
|
+
CREATE TABLE paint_colors(
|
86
|
+
id SERIAL(100),
|
87
|
+
non_poly_one_id INT,
|
88
|
+
PRIMARY KEY (id)
|
89
|
+
);
|
90
|
+
_SQL
|
91
|
+
|
92
|
+
execute <<_SQL
|
93
|
+
CREATE TABLE paint_textures(
|
94
|
+
id SERIAL(100),
|
95
|
+
non_poly_two_id INT,
|
96
|
+
PRIMARY KEY (id)
|
97
|
+
);
|
98
|
+
_SQL
|
99
|
+
|
100
|
+
execute <<_SQL
|
101
|
+
CREATE TABLE topics (
|
102
|
+
id SERIAL(100),
|
103
|
+
title VARCHAR(255) DEFAULT NULL,
|
104
|
+
author_name VARCHAR(255) DEFAULT NULL,
|
105
|
+
author_email_address VARCHAR(255) DEFAULT NULL,
|
106
|
+
written_on DATETIME YEAR TO FRACTION(5) DEFAULT NULL,
|
107
|
+
bonus_time DATETIME YEAR TO FRACTION(5) DEFAULT NULL,
|
108
|
+
--bonus_time DATETIME HOUR TO SECOND DEFAULT NULL,
|
109
|
+
last_read DATE DEFAULT NULL,
|
110
|
+
content LVARCHAR(3000),
|
111
|
+
approved SMALLINT DEFAULT 1,
|
112
|
+
replies_count INT DEFAULT 0,
|
113
|
+
parent_id INT DEFAULT NULL,
|
114
|
+
type VARCHAR(50) DEFAULT NULL,
|
115
|
+
PRIMARY KEY (id)
|
116
|
+
);
|
117
|
+
|
118
|
+
_SQL
|
119
|
+
|
120
|
+
execute <<_SQL
|
121
|
+
CREATE TABLE fk_test_has_pk (
|
122
|
+
id INT NOT NULL PRIMARY KEY
|
123
|
+
);
|
124
|
+
|
125
|
+
_SQL
|
126
|
+
|
127
|
+
execute <<_SQL
|
128
|
+
CREATE TABLE fk_test_has_fk (
|
129
|
+
id INT NOT NULL PRIMARY KEY,
|
130
|
+
fk_id INT NOT NULL,
|
131
|
+
FOREIGN KEY (fk_id) REFERENCES fk_test_has_pk(id)
|
132
|
+
);
|
133
|
+
|
134
|
+
_SQL
|
135
|
+
|
136
|
+
end
|
@@ -0,0 +1,133 @@
|
|
1
|
+
ActiveRecord::Schema.define do
|
2
|
+
|
3
|
+
execute "DROP TABLE COMMENTS" rescue nil
|
4
|
+
execute "DROP TABLE POSTS" rescue nil
|
5
|
+
execute "DROP TABLE ITEMS" rescue nil
|
6
|
+
execute "DROP TABLE TOPICS" rescue nil
|
7
|
+
execute "DROP TABLE fk_test_has_fk" rescue nil
|
8
|
+
execute "DROP TABLE fk_test_has_pk" rescue nil
|
9
|
+
execute "DROP TABLE CIRCLES" rescue nil
|
10
|
+
execute "DROP TABLE SQUARES" rescue nil
|
11
|
+
execute "DROP TABLE TRIANGLES" rescue nil
|
12
|
+
execute "DROP TABLE NON_POLY_ONES" rescue nil
|
13
|
+
execute "DROP TABLE NON_POLY_TWOS" rescue nil
|
14
|
+
execute "DROP TABLE PAINT_COLORS" rescue nil
|
15
|
+
execute "DROP TABLE PAINT_TEXTURES" rescue nil
|
16
|
+
|
17
|
+
execute <<_SQL
|
18
|
+
CREATE TABLE comments (
|
19
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 100),
|
20
|
+
post_id INT NOT NULL,
|
21
|
+
type VARCHAR(255) DEFAULT NULL,
|
22
|
+
body VARCHAR(3000)NOT NULL,
|
23
|
+
PRIMARY KEY (id)
|
24
|
+
);
|
25
|
+
_SQL
|
26
|
+
|
27
|
+
execute <<_SQL
|
28
|
+
CREATE TABLE posts (
|
29
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 100),
|
30
|
+
author_id INT DEFAULT NULL,
|
31
|
+
title VARCHAR(255) NOT NULL,
|
32
|
+
type VARCHAR(255) DEFAULT NULL,
|
33
|
+
body VARCHAR(3000) NOT NULL,
|
34
|
+
comments_count integer DEFAULT 0,
|
35
|
+
taggings_count integer DEFAULT 0,
|
36
|
+
PRIMARY KEY (id)
|
37
|
+
);
|
38
|
+
_SQL
|
39
|
+
|
40
|
+
execute <<_SQL
|
41
|
+
CREATE TABLE fk_test_has_pk (
|
42
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 100),
|
43
|
+
PRIMARY KEY (id)
|
44
|
+
);
|
45
|
+
_SQL
|
46
|
+
|
47
|
+
execute <<_SQL
|
48
|
+
CREATE TABLE fk_test_has_fk (
|
49
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 100),
|
50
|
+
fk_id integer NOT NULL,
|
51
|
+
PRIMARY KEY (id),
|
52
|
+
FOREIGN KEY (fk_id) REFERENCES fk_test_has_pk(id)
|
53
|
+
);
|
54
|
+
_SQL
|
55
|
+
|
56
|
+
execute <<_SQL
|
57
|
+
CREATE TABLE items (
|
58
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 100),
|
59
|
+
name VARCHAR(255) DEFAULT NULL,
|
60
|
+
PRIMARY KEY (id)
|
61
|
+
);
|
62
|
+
_SQL
|
63
|
+
|
64
|
+
execute <<_SQL
|
65
|
+
CREATE TABLE circles (
|
66
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 1),
|
67
|
+
PRIMARY KEY (id)
|
68
|
+
);
|
69
|
+
_SQL
|
70
|
+
|
71
|
+
execute <<_SQL
|
72
|
+
CREATE TABLE squares(
|
73
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 1),
|
74
|
+
PRIMARY KEY (id)
|
75
|
+
);
|
76
|
+
_SQL
|
77
|
+
|
78
|
+
execute <<_SQL
|
79
|
+
CREATE TABLE triangles(
|
80
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 1),
|
81
|
+
PRIMARY KEY (id)
|
82
|
+
);
|
83
|
+
_SQL
|
84
|
+
|
85
|
+
execute <<_SQL
|
86
|
+
CREATE TABLE non_poly_ones(
|
87
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 1),
|
88
|
+
PRIMARY KEY (id)
|
89
|
+
);
|
90
|
+
_SQL
|
91
|
+
|
92
|
+
execute <<_SQL
|
93
|
+
CREATE TABLE non_poly_twos(
|
94
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 1),
|
95
|
+
PRIMARY KEY (id)
|
96
|
+
);
|
97
|
+
_SQL
|
98
|
+
|
99
|
+
execute <<_SQL
|
100
|
+
CREATE TABLE paint_colors(
|
101
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 1),
|
102
|
+
non_poly_one_id INT,
|
103
|
+
PRIMARY KEY (id)
|
104
|
+
);
|
105
|
+
_SQL
|
106
|
+
|
107
|
+
execute <<_SQL
|
108
|
+
CREATE TABLE paint_textures(
|
109
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 1),
|
110
|
+
non_poly_two_id INT,
|
111
|
+
PRIMARY KEY (id)
|
112
|
+
);
|
113
|
+
_SQL
|
114
|
+
|
115
|
+
execute <<_SQL
|
116
|
+
CREATE TABLE topics (
|
117
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 100),
|
118
|
+
title VARCHAR(255) DEFAULT NULL,
|
119
|
+
author_name VARCHAR(255) DEFAULT NULL,
|
120
|
+
author_email_address VARCHAR(255) DEFAULT NULL,
|
121
|
+
written_on TIMESTAMP DEFAULT NULL,
|
122
|
+
bonus_time TIME DEFAULT NULL,
|
123
|
+
last_read DATE DEFAULT NULL,
|
124
|
+
content VARCHAR(3000),
|
125
|
+
approved SMALLINT DEFAULT 1,
|
126
|
+
replies_count INT DEFAULT 0,
|
127
|
+
parent_id INT DEFAULT NULL,
|
128
|
+
type VARCHAR(255) DEFAULT NULL,
|
129
|
+
PRIMARY KEY (id)
|
130
|
+
);
|
131
|
+
_SQL
|
132
|
+
|
133
|
+
end
|
@@ -0,0 +1,432 @@
|
|
1
|
+
|
2
|
+
ActiveRecord::Schema.define do
|
3
|
+
def except(adapter_names_to_exclude)
|
4
|
+
unless [adapter_names_to_exclude].flatten.include?(adapter_name)
|
5
|
+
yield
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
#put adapter specific setup here
|
10
|
+
case adapter_name
|
11
|
+
# For Firebird, set the sequence values 10000 when create_table is called;
|
12
|
+
# this prevents primary key collisions between "normally" created records
|
13
|
+
# and fixture-based (YAML) records.
|
14
|
+
when "Firebird"
|
15
|
+
def create_table(*args, &block)
|
16
|
+
ActiveRecord::Base.connection.create_table(*args, &block)
|
17
|
+
ActiveRecord::Base.connection.execute "SET GENERATOR #{args.first}_seq TO 10000"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
# Please keep these create table statements in alphabetical order
|
23
|
+
# unless the ordering matters. In which case, define them below
|
24
|
+
create_table :accounts, :force => true do |t|
|
25
|
+
t.integer :firm_id
|
26
|
+
t.integer :credit_limit
|
27
|
+
end
|
28
|
+
|
29
|
+
create_table :audit_logs, :force => true do |t|
|
30
|
+
t.column :message, :string, :null=>false
|
31
|
+
t.column :developer_id, :integer, :null=>false
|
32
|
+
end
|
33
|
+
|
34
|
+
create_table :authors, :force => true do |t|
|
35
|
+
t.string :name, :null => false
|
36
|
+
t.integer :author_address_id
|
37
|
+
t.integer :author_address_extra_id
|
38
|
+
end
|
39
|
+
|
40
|
+
create_table :author_addresses, :force => true do |t|
|
41
|
+
end
|
42
|
+
|
43
|
+
create_table :author_favorites, :force => true do |t|
|
44
|
+
t.column :author_id, :integer
|
45
|
+
t.column :favorite_author_id, :integer
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
create_table :auto_id_tests, :force => true, :id => false do |t|
|
50
|
+
t.primary_key :auto_id
|
51
|
+
t.integer :value
|
52
|
+
end
|
53
|
+
|
54
|
+
create_table :binaries, :force => true do |t|
|
55
|
+
t.binary :data
|
56
|
+
end
|
57
|
+
|
58
|
+
create_table :books, :force => true do |t|
|
59
|
+
t.column :name, :string
|
60
|
+
end
|
61
|
+
|
62
|
+
create_table :booleantests, :force => true do |t|
|
63
|
+
t.integer :value
|
64
|
+
end
|
65
|
+
|
66
|
+
create_table :categories, :force => true do |t|
|
67
|
+
t.string :name, :null => false
|
68
|
+
t.string :type
|
69
|
+
end
|
70
|
+
|
71
|
+
create_table :categories_posts, :force => true, :id => false do |t|
|
72
|
+
t.integer :category_id, :null => false
|
73
|
+
t.integer :post_id, :null => false
|
74
|
+
end
|
75
|
+
|
76
|
+
create_table :categorizations, :force => true do |t|
|
77
|
+
t.column :category_id, :integer
|
78
|
+
t.column :post_id, :integer
|
79
|
+
t.column :author_id, :integer
|
80
|
+
end
|
81
|
+
|
82
|
+
create_table :citations, :force => true do |t|
|
83
|
+
t.column :book1_id, :integer
|
84
|
+
t.column :book2_id, :integer
|
85
|
+
end
|
86
|
+
|
87
|
+
create_table :clubs, :force => true do |t|
|
88
|
+
t.string :name
|
89
|
+
end
|
90
|
+
|
91
|
+
create_table :colnametests, :force => true do |t|
|
92
|
+
t.integer :references, :null => false
|
93
|
+
end
|
94
|
+
|
95
|
+
except 'IBM_DB' do
|
96
|
+
create_table :comments, :force => true do |t|
|
97
|
+
t.integer :post_id, :null => false
|
98
|
+
t.text :body, :null => false
|
99
|
+
t.string :type
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
create_table :companies, :force => true do |t|
|
104
|
+
t.string :type
|
105
|
+
t.string :ruby_type
|
106
|
+
t.integer :firm_id
|
107
|
+
t.string :name
|
108
|
+
t.integer :client_of
|
109
|
+
t.integer :rating, :default => 1
|
110
|
+
end
|
111
|
+
|
112
|
+
create_table :computers, :force => true do |t|
|
113
|
+
t.integer :developer, :null => false
|
114
|
+
t.integer :extendedWarranty, :null => false
|
115
|
+
end
|
116
|
+
|
117
|
+
|
118
|
+
create_table :customers, :force => true do |t|
|
119
|
+
t.string :name
|
120
|
+
t.integer :balance, :default => 0
|
121
|
+
t.string :address_street
|
122
|
+
t.string :address_city
|
123
|
+
t.string :address_country
|
124
|
+
t.string :gps_location
|
125
|
+
end
|
126
|
+
|
127
|
+
create_table :developers, :force => true do |t|
|
128
|
+
t.string :name
|
129
|
+
t.integer :salary, :default => 70000
|
130
|
+
t.datetime :created_at
|
131
|
+
t.datetime :updated_at
|
132
|
+
end
|
133
|
+
|
134
|
+
create_table :developers_projects, :force => true, :id => false do |t|
|
135
|
+
t.integer :developer_id, :null => false
|
136
|
+
t.integer :project_id, :null => false
|
137
|
+
t.date :joined_on
|
138
|
+
t.integer :access_level, :default => 1
|
139
|
+
end
|
140
|
+
|
141
|
+
create_table :edges, :force => true do |t|
|
142
|
+
t.column :source_id, :integer, :null => false
|
143
|
+
t.column :sink_id, :integer, :null => false
|
144
|
+
end
|
145
|
+
add_index :edges, [:source_id, :sink_id], :unique => true, :name => 'unique_edge_index'
|
146
|
+
|
147
|
+
|
148
|
+
create_table :entrants, :force => true do |t|
|
149
|
+
t.string :name, :null => false
|
150
|
+
t.integer :course_id, :null => false
|
151
|
+
end
|
152
|
+
|
153
|
+
create_table :funny_jokes, :force => true do |t|
|
154
|
+
t.string :name
|
155
|
+
end
|
156
|
+
|
157
|
+
except 'IBM_DB' do
|
158
|
+
create_table :items, :force => true do |t|
|
159
|
+
t.column :name, :string
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
create_table :inept_wizards, :force => true do |t|
|
164
|
+
t.column :name, :string, :null => false
|
165
|
+
t.column :city, :string, :null => false
|
166
|
+
t.column :type, :string
|
167
|
+
end
|
168
|
+
|
169
|
+
|
170
|
+
create_table :jobs, :force => true do |t|
|
171
|
+
t.integer :ideal_reference_id
|
172
|
+
end
|
173
|
+
|
174
|
+
create_table :keyboards, :force => true, :id => false do |t|
|
175
|
+
t.primary_key :key_number
|
176
|
+
t.string :name
|
177
|
+
end
|
178
|
+
|
179
|
+
create_table :legacy_things, :force => true do |t|
|
180
|
+
t.integer :tps_report_number
|
181
|
+
t.integer :version, :null => false, :default => 0
|
182
|
+
end
|
183
|
+
|
184
|
+
create_table :lock_without_defaults, :force => true do |t|
|
185
|
+
t.column :lock_version, :integer
|
186
|
+
end
|
187
|
+
|
188
|
+
create_table :lock_without_defaults_cust, :force => true do |t|
|
189
|
+
t.column :custom_lock_version, :integer
|
190
|
+
end
|
191
|
+
|
192
|
+
create_table :mateys, :id => false, :force => true do |t|
|
193
|
+
t.column :pirate_id, :integer
|
194
|
+
t.column :target_id, :integer
|
195
|
+
t.column :weight, :integer
|
196
|
+
end
|
197
|
+
|
198
|
+
create_table :members, :force => true do |t|
|
199
|
+
t.string :name
|
200
|
+
end
|
201
|
+
|
202
|
+
create_table :memberships, :force => true do |t|
|
203
|
+
t.datetime :joined_on
|
204
|
+
t.integer :club_id, :member_id
|
205
|
+
t.boolean :favourite, :default => false
|
206
|
+
t.string :type
|
207
|
+
end
|
208
|
+
|
209
|
+
create_table :references, :force => true do |t|
|
210
|
+
t.integer :person_id
|
211
|
+
t.integer :job_id
|
212
|
+
t.boolean :favourite
|
213
|
+
t.integer :lock_version, :default => 0
|
214
|
+
end
|
215
|
+
|
216
|
+
create_table :minimalistics, :force => true do |t|
|
217
|
+
end
|
218
|
+
|
219
|
+
create_table :mixed_case_monkeys, :force => true, :id => false do |t|
|
220
|
+
t.primary_key :monkeyID
|
221
|
+
t.integer :fleaCount
|
222
|
+
end
|
223
|
+
|
224
|
+
create_table :mixins, :force => true do |t|
|
225
|
+
t.integer :parent_id
|
226
|
+
t.integer :pos
|
227
|
+
t.datetime :created_at
|
228
|
+
t.datetime :updated_at
|
229
|
+
t.integer :lft
|
230
|
+
t.integer :rgt
|
231
|
+
t.integer :root_id
|
232
|
+
t.string :type
|
233
|
+
end
|
234
|
+
|
235
|
+
create_table :movies, :force => true, :id => false do |t|
|
236
|
+
t.primary_key :movieid
|
237
|
+
t.string :name
|
238
|
+
end
|
239
|
+
|
240
|
+
create_table :numeric_data, :force => true do |t|
|
241
|
+
t.decimal :bank_balance, :precision => 10, :scale => 2
|
242
|
+
t.decimal :big_bank_balance, :precision => 15, :scale => 2
|
243
|
+
t.decimal :world_population, :precision => 10, :scale => 0
|
244
|
+
t.decimal :my_house_population, :precision => 2, :scale => 0
|
245
|
+
t.decimal :decimal_number_with_default, :precision => 3, :scale => 2, :default => 2.78
|
246
|
+
end
|
247
|
+
|
248
|
+
create_table :orders, :force => true do |t|
|
249
|
+
t.string :name
|
250
|
+
t.integer :billing_customer_id
|
251
|
+
t.integer :shipping_customer_id
|
252
|
+
end
|
253
|
+
|
254
|
+
create_table :owners, :primary_key => :owner_id ,:force => true do |t|
|
255
|
+
t.string :name
|
256
|
+
end
|
257
|
+
|
258
|
+
except 'IBM_DB' do
|
259
|
+
create_table :paint_colors, :force => true do |t|
|
260
|
+
t.integer :non_poly_one_id
|
261
|
+
end
|
262
|
+
|
263
|
+
create_table :paint_textures, :force => true do |t|
|
264
|
+
t.integer :non_poly_two_id
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
create_table :parrots, :force => true do |t|
|
269
|
+
t.column :name, :string
|
270
|
+
t.column :parrot_sti_class, :string
|
271
|
+
t.column :killer_id, :integer
|
272
|
+
t.column :created_at, :datetime
|
273
|
+
t.column :created_on, :datetime
|
274
|
+
t.column :updated_at, :datetime
|
275
|
+
t.column :updated_on, :datetime
|
276
|
+
end
|
277
|
+
|
278
|
+
create_table :parrots_pirates, :id => false, :force => true do |t|
|
279
|
+
t.column :parrot_id, :integer
|
280
|
+
t.column :pirate_id, :integer
|
281
|
+
end
|
282
|
+
|
283
|
+
create_table :parrots_treasures, :id => false, :force => true do |t|
|
284
|
+
t.column :parrot_id, :integer
|
285
|
+
t.column :treasure_id, :integer
|
286
|
+
end
|
287
|
+
|
288
|
+
create_table :people, :force => true do |t|
|
289
|
+
t.string :first_name, :null => false
|
290
|
+
t.integer :lock_version, :null => false, :default => 0
|
291
|
+
end
|
292
|
+
|
293
|
+
create_table :pets, :primary_key => :pet_id ,:force => true do |t|
|
294
|
+
t.string :name
|
295
|
+
t.integer :owner_id, :integer
|
296
|
+
end
|
297
|
+
|
298
|
+
create_table :pirates, :force => true do |t|
|
299
|
+
t.column :catchphrase, :string
|
300
|
+
t.column :parrot_id, :integer
|
301
|
+
t.column :created_on, :datetime
|
302
|
+
t.column :updated_on, :datetime
|
303
|
+
end
|
304
|
+
|
305
|
+
except 'IBM_DB' do
|
306
|
+
create_table :posts, :force => true do |t|
|
307
|
+
t.integer :author_id
|
308
|
+
t.string :title, :null => false
|
309
|
+
t.text :body, :null => false
|
310
|
+
t.string :type
|
311
|
+
t.integer :comments_count, :default => 0
|
312
|
+
t.integer :taggings_count, :default => 0
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
316
|
+
create_table :price_estimates, :force => true do |t|
|
317
|
+
t.string :estimate_of_type
|
318
|
+
t.integer :estimate_of_id
|
319
|
+
t.integer :price
|
320
|
+
end
|
321
|
+
|
322
|
+
create_table :projects, :force => true do |t|
|
323
|
+
t.string :name
|
324
|
+
t.string :type
|
325
|
+
end
|
326
|
+
|
327
|
+
create_table :readers, :force => true do |t|
|
328
|
+
t.integer :post_id, :null => false
|
329
|
+
t.integer :person_id, :null => false
|
330
|
+
end
|
331
|
+
|
332
|
+
create_table :shape_expressions, :force => true do |t|
|
333
|
+
t.string :paint_type
|
334
|
+
t.integer :paint_id
|
335
|
+
t.string :shape_type
|
336
|
+
t.integer :shape_id
|
337
|
+
end
|
338
|
+
|
339
|
+
create_table :ships, :force => true do |t|
|
340
|
+
t.string :name
|
341
|
+
t.datetime :created_at
|
342
|
+
t.datetime :created_on
|
343
|
+
t.datetime :updated_at
|
344
|
+
t.datetime :updated_on
|
345
|
+
end
|
346
|
+
|
347
|
+
create_table :sponsors, :force => true do |t|
|
348
|
+
t.integer :club_id
|
349
|
+
t.integer :sponsorable_id
|
350
|
+
t.string :sponsorable_type
|
351
|
+
end
|
352
|
+
|
353
|
+
create_table :subscribers, :force => true, :id => false do |t|
|
354
|
+
t.string :nick, :null => false
|
355
|
+
t.string :name
|
356
|
+
end
|
357
|
+
add_index :subscribers, :nick, :unique => true
|
358
|
+
|
359
|
+
create_table :subscriptions, :force => true do |t|
|
360
|
+
t.string :subscriber_id
|
361
|
+
t.integer :book_id
|
362
|
+
end
|
363
|
+
|
364
|
+
create_table :tasks, :force => true do |t|
|
365
|
+
t.datetime :starting
|
366
|
+
t.datetime :ending
|
367
|
+
end
|
368
|
+
|
369
|
+
except 'IBM_DB' do
|
370
|
+
create_table :topics, :force => true do |t|
|
371
|
+
t.string :title
|
372
|
+
t.string :author_name
|
373
|
+
t.string :author_email_address
|
374
|
+
t.datetime :written_on
|
375
|
+
t.time :bonus_time
|
376
|
+
t.date :last_read
|
377
|
+
t.text :content
|
378
|
+
t.boolean :approved, :default => true
|
379
|
+
t.integer :replies_count, :default => 0
|
380
|
+
t.integer :parent_id
|
381
|
+
t.string :type
|
382
|
+
end
|
383
|
+
end
|
384
|
+
|
385
|
+
create_table :taggings, :force => true do |t|
|
386
|
+
t.column :tag_id, :integer
|
387
|
+
t.column :super_tag_id, :integer
|
388
|
+
t.column :taggable_type, :string
|
389
|
+
t.column :taggable_id, :integer
|
390
|
+
end
|
391
|
+
|
392
|
+
create_table :tags, :force => true do |t|
|
393
|
+
t.column :name, :string
|
394
|
+
t.column :taggings_count, :integer, :default => 0
|
395
|
+
end
|
396
|
+
|
397
|
+
create_table :treasures, :force => true do |t|
|
398
|
+
t.column :name, :string
|
399
|
+
t.column :looter_id, :integer
|
400
|
+
t.column :looter_type, :string
|
401
|
+
end
|
402
|
+
|
403
|
+
create_table :vertices, :force => true do |t|
|
404
|
+
t.column :label, :string
|
405
|
+
end
|
406
|
+
|
407
|
+
create_table 'warehouse_things', :force => true do |t|
|
408
|
+
t.integer :value
|
409
|
+
end
|
410
|
+
|
411
|
+
except 'IBM_DB' do
|
412
|
+
[:circles, :squares, :triangles, :non_poly_ones, :non_poly_twos].each do |t|
|
413
|
+
create_table(t, :force => true) { }
|
414
|
+
end
|
415
|
+
end
|
416
|
+
|
417
|
+
create_table :guids, :force => true do |t|
|
418
|
+
t.column :key, :string
|
419
|
+
end
|
420
|
+
|
421
|
+
except ['SQLite','IBM_DB'] do
|
422
|
+
# fk_test_has_fk should be before fk_test_has_pk
|
423
|
+
create_table :fk_test_has_fk, :force => true do |t|
|
424
|
+
t.integer :fk_id, :null => false
|
425
|
+
end
|
426
|
+
|
427
|
+
create_table :fk_test_has_pk, :force => true do |t|
|
428
|
+
end
|
429
|
+
|
430
|
+
execute "ALTER TABLE fk_test_has_fk ADD CONSTRAINT fk_name FOREIGN KEY (#{quote_column_name 'fk_id'}) REFERENCES #{quote_table_name 'fk_test_has_pk'} (#{quote_column_name 'id'})"
|
431
|
+
end
|
432
|
+
end
|