activerecord 1.15.6 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activerecord might be problematic. Click here for more details.
- data/CHANGELOG +2454 -34
- data/README +1 -1
- data/RUNNING_UNIT_TESTS +3 -34
- data/Rakefile +98 -77
- data/install.rb +1 -1
- data/lib/active_record.rb +13 -22
- data/lib/active_record/aggregations.rb +38 -49
- data/lib/active_record/associations.rb +452 -333
- data/lib/active_record/associations/association_collection.rb +66 -20
- data/lib/active_record/associations/association_proxy.rb +9 -8
- data/lib/active_record/associations/has_and_belongs_to_many_association.rb +46 -51
- data/lib/active_record/associations/has_many_association.rb +21 -57
- data/lib/active_record/associations/has_many_through_association.rb +38 -18
- data/lib/active_record/associations/has_one_association.rb +30 -14
- data/lib/active_record/attribute_methods.rb +253 -0
- data/lib/active_record/base.rb +719 -494
- data/lib/active_record/calculations.rb +62 -63
- data/lib/active_record/callbacks.rb +57 -83
- data/lib/active_record/connection_adapters/abstract/connection_specification.rb +38 -9
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +56 -15
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +87 -0
- data/lib/active_record/connection_adapters/abstract/quoting.rb +23 -12
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +191 -62
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +37 -34
- data/lib/active_record/connection_adapters/abstract_adapter.rb +28 -17
- data/lib/active_record/connection_adapters/mysql_adapter.rb +119 -37
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +473 -210
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +34 -0
- data/lib/active_record/connection_adapters/sqlite_adapter.rb +91 -107
- data/lib/active_record/fixtures.rb +503 -113
- data/lib/active_record/locking/optimistic.rb +72 -34
- data/lib/active_record/migration.rb +80 -57
- data/lib/active_record/observer.rb +13 -10
- data/lib/active_record/query_cache.rb +16 -57
- data/lib/active_record/reflection.rb +35 -38
- data/lib/active_record/schema.rb +5 -5
- data/lib/active_record/schema_dumper.rb +35 -13
- data/lib/active_record/serialization.rb +98 -0
- data/lib/active_record/serializers/json_serializer.rb +71 -0
- data/lib/active_record/{xml_serialization.rb → serializers/xml_serializer.rb} +90 -83
- data/lib/active_record/timestamp.rb +20 -21
- data/lib/active_record/transactions.rb +39 -43
- data/lib/active_record/validations.rb +256 -107
- data/lib/active_record/version.rb +3 -3
- data/lib/activerecord.rb +1 -0
- data/test/aaa_create_tables_test.rb +15 -2
- data/test/abstract_unit.rb +24 -17
- data/test/active_schema_test_mysql.rb +20 -8
- data/test/adapter_test.rb +23 -5
- data/test/adapter_test_sqlserver.rb +15 -1
- data/test/aggregations_test.rb +16 -1
- data/test/all.sh +2 -2
- data/test/associations/ar_joins_test.rb +0 -0
- data/test/associations/callbacks_test.rb +51 -30
- data/test/associations/cascaded_eager_loading_test.rb +1 -29
- data/test/associations/eager_singularization_test.rb +145 -0
- data/test/associations/eager_test.rb +42 -6
- data/test/associations/extension_test.rb +6 -1
- data/test/associations/inner_join_association_test.rb +88 -0
- data/test/associations/join_model_test.rb +47 -16
- data/test/associations_test.rb +449 -226
- data/test/attribute_methods_test.rb +97 -0
- data/test/base_test.rb +251 -105
- data/test/binary_test.rb +22 -27
- data/test/calculations_test.rb +37 -5
- data/test/callbacks_test.rb +23 -0
- data/test/connection_test_firebird.rb +2 -2
- data/test/connection_test_mysql.rb +30 -0
- data/test/connections/native_mysql/connection.rb +3 -0
- data/test/connections/native_sqlite/connection.rb +5 -14
- data/test/connections/native_sqlite3/connection.rb +5 -14
- data/test/connections/native_sqlite3/in_memory_connection.rb +1 -1
- data/test/{copy_table_sqlite.rb → copy_table_test_sqlite.rb} +8 -3
- data/test/datatype_test_postgresql.rb +178 -27
- data/test/{empty_date_time_test.rb → date_time_test.rb} +13 -1
- data/test/defaults_test.rb +8 -1
- data/test/deprecated_finder_test.rb +7 -128
- data/test/finder_test.rb +192 -54
- data/test/fixtures/all/developers.yml +0 -0
- data/test/fixtures/all/people.csv +0 -0
- data/test/fixtures/all/tasks.yml +0 -0
- data/test/fixtures/author.rb +12 -5
- data/test/fixtures/binaries.yml +130 -435
- data/test/fixtures/category.rb +6 -0
- data/test/fixtures/company.rb +8 -1
- data/test/fixtures/computer.rb +1 -0
- data/test/fixtures/contact.rb +16 -0
- data/test/fixtures/customer.rb +2 -2
- data/test/fixtures/db_definitions/db2.drop.sql +1 -0
- data/test/fixtures/db_definitions/db2.sql +4 -0
- data/test/fixtures/db_definitions/firebird.drop.sql +3 -1
- data/test/fixtures/db_definitions/firebird.sql +6 -0
- data/test/fixtures/db_definitions/frontbase.drop.sql +1 -0
- data/test/fixtures/db_definitions/frontbase.sql +5 -0
- data/test/fixtures/db_definitions/openbase.sql +41 -25
- data/test/fixtures/db_definitions/oracle.drop.sql +2 -0
- data/test/fixtures/db_definitions/oracle.sql +5 -0
- data/test/fixtures/db_definitions/postgresql.drop.sql +7 -0
- data/test/fixtures/db_definitions/postgresql.sql +87 -58
- data/test/fixtures/db_definitions/postgresql2.sql +1 -2
- data/test/fixtures/db_definitions/schema.rb +280 -0
- data/test/fixtures/db_definitions/schema2.rb +11 -0
- data/test/fixtures/db_definitions/sqlite.drop.sql +1 -0
- data/test/fixtures/db_definitions/sqlite.sql +4 -0
- data/test/fixtures/db_definitions/sybase.drop.sql +1 -0
- data/test/fixtures/db_definitions/sybase.sql +4 -0
- data/test/fixtures/developer.rb +10 -0
- data/test/fixtures/example.log +1 -0
- data/test/fixtures/flowers.jpg +0 -0
- data/test/fixtures/item.rb +7 -0
- data/test/fixtures/items.yml +4 -0
- data/test/fixtures/joke.rb +0 -3
- data/test/fixtures/matey.rb +4 -0
- data/test/fixtures/mateys.yml +4 -0
- data/test/fixtures/minimalistic.rb +2 -0
- data/test/fixtures/minimalistics.yml +2 -0
- data/test/fixtures/mixins.yml +2 -100
- data/test/fixtures/parrot.rb +13 -0
- data/test/fixtures/parrots.yml +27 -0
- data/test/fixtures/parrots_pirates.yml +7 -0
- data/test/fixtures/pirate.rb +5 -0
- data/test/fixtures/pirates.yml +9 -0
- data/test/fixtures/post.rb +1 -0
- data/test/fixtures/project.rb +3 -2
- data/test/fixtures/reserved_words/distinct.yml +5 -0
- data/test/fixtures/reserved_words/distincts_selects.yml +11 -0
- data/test/fixtures/reserved_words/group.yml +14 -0
- data/test/fixtures/reserved_words/select.yml +8 -0
- data/test/fixtures/reserved_words/values.yml +7 -0
- data/test/fixtures/ship.rb +3 -0
- data/test/fixtures/ships.yml +5 -0
- data/test/fixtures/tagging.rb +4 -0
- data/test/fixtures/taggings.yml +8 -1
- data/test/fixtures/topic.rb +13 -1
- data/test/fixtures/treasure.rb +4 -0
- data/test/fixtures/treasures.yml +10 -0
- data/test/fixtures_test.rb +205 -24
- data/test/inheritance_test.rb +7 -1
- data/test/json_serialization_test.rb +180 -0
- data/test/lifecycle_test.rb +1 -1
- data/test/locking_test.rb +85 -2
- data/test/migration_test.rb +206 -40
- data/test/mixin_test.rb +13 -515
- data/test/pk_test.rb +3 -6
- data/test/query_cache_test.rb +104 -0
- data/test/reflection_test.rb +16 -0
- data/test/reserved_word_test_mysql.rb +177 -0
- data/test/schema_dumper_test.rb +38 -3
- data/test/serialization_test.rb +47 -0
- data/test/transactions_test.rb +74 -23
- data/test/unconnected_test.rb +1 -1
- data/test/validations_test.rb +322 -32
- data/test/xml_serialization_test.rb +121 -44
- metadata +48 -41
- data/examples/associations.rb +0 -87
- data/examples/shared_setup.rb +0 -15
- data/examples/validation.rb +0 -85
- data/lib/active_record/acts/list.rb +0 -256
- data/lib/active_record/acts/nested_set.rb +0 -211
- data/lib/active_record/acts/tree.rb +0 -96
- data/lib/active_record/connection_adapters/db2_adapter.rb +0 -228
- data/lib/active_record/connection_adapters/firebird_adapter.rb +0 -728
- data/lib/active_record/connection_adapters/frontbase_adapter.rb +0 -861
- data/lib/active_record/connection_adapters/openbase_adapter.rb +0 -350
- data/lib/active_record/connection_adapters/oracle_adapter.rb +0 -690
- data/lib/active_record/connection_adapters/sqlserver_adapter.rb +0 -591
- data/lib/active_record/connection_adapters/sybase_adapter.rb +0 -662
- data/lib/active_record/deprecated_associations.rb +0 -104
- data/lib/active_record/deprecated_finders.rb +0 -44
- data/lib/active_record/vendor/simple.rb +0 -693
- data/lib/active_record/wrappers/yaml_wrapper.rb +0 -15
- data/lib/active_record/wrappings.rb +0 -58
- data/test/connections/native_sqlserver/connection.rb +0 -23
- data/test/connections/native_sqlserver_odbc/connection.rb +0 -25
- data/test/deprecated_associations_test.rb +0 -396
- data/test/fixtures/db_definitions/mysql.drop.sql +0 -32
- data/test/fixtures/db_definitions/mysql.sql +0 -234
- data/test/fixtures/db_definitions/mysql2.drop.sql +0 -2
- data/test/fixtures/db_definitions/mysql2.sql +0 -5
- data/test/fixtures/db_definitions/sqlserver.drop.sql +0 -34
- data/test/fixtures/db_definitions/sqlserver.sql +0 -243
- data/test/fixtures/db_definitions/sqlserver2.drop.sql +0 -2
- data/test/fixtures/db_definitions/sqlserver2.sql +0 -5
- data/test/fixtures/mixin.rb +0 -63
- data/test/mixin_nested_set_test.rb +0 -196
data/test/fixtures/category.rb
CHANGED
@@ -3,6 +3,12 @@ class Category < ActiveRecord::Base
|
|
3
3
|
has_and_belongs_to_many :special_posts, :class_name => "Post"
|
4
4
|
has_and_belongs_to_many :other_posts, :class_name => "Post"
|
5
5
|
|
6
|
+
has_and_belongs_to_many(:select_testing_posts,
|
7
|
+
:class_name => 'Post',
|
8
|
+
:foreign_key => 'category_id',
|
9
|
+
:association_foreign_key => 'post_id',
|
10
|
+
:select => 'posts.*, 1 as correctness_marker')
|
11
|
+
|
6
12
|
def self.what_are_you
|
7
13
|
'a category...'
|
8
14
|
end
|
data/test/fixtures/company.rb
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
-
class
|
1
|
+
class AbstractCompany < ActiveRecord::Base
|
2
|
+
self.abstract_class = true
|
3
|
+
end
|
4
|
+
|
5
|
+
class Company < AbstractCompany
|
2
6
|
attr_protected :rating
|
3
7
|
set_sequence_name :companies_nonstd_seq
|
4
8
|
|
@@ -34,6 +38,7 @@ class Firm < Company
|
|
34
38
|
has_many :no_clients_using_counter_sql, :class_name => "Client",
|
35
39
|
:finder_sql => 'SELECT * FROM companies WHERE client_of = 1000',
|
36
40
|
:counter_sql => 'SELECT COUNT(*) FROM companies WHERE client_of = 1000'
|
41
|
+
has_many :clients_using_finder_sql, :class_name => "Client", :finder_sql => 'SELECT * FROM companies WHERE 1=1'
|
37
42
|
has_many :plain_clients, :class_name => 'Client'
|
38
43
|
|
39
44
|
has_one :account, :foreign_key => "firm_id", :dependent => :destroy
|
@@ -46,6 +51,8 @@ end
|
|
46
51
|
|
47
52
|
class ExclusivelyDependentFirm < Company
|
48
53
|
has_one :account, :foreign_key => "firm_id", :dependent => :delete
|
54
|
+
has_many :dependent_sanitized_conditional_clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id", :dependent => :delete_all, :conditions => "name = 'BigShot Inc.'"
|
55
|
+
has_many :dependent_conditional_clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id", :dependent => :delete_all, :conditions => ["name = ?", 'BigShot Inc.']
|
49
56
|
end
|
50
57
|
|
51
58
|
class Client < Company
|
data/test/fixtures/computer.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
class Contact < ActiveRecord::Base
|
2
|
+
# mock out self.columns so no pesky db is needed for these tests
|
3
|
+
def self.column(name, sql_type = nil, options = {})
|
4
|
+
@columns ||= []
|
5
|
+
@columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, options[:default], sql_type.to_s, options[:null])
|
6
|
+
end
|
7
|
+
|
8
|
+
column :name, :string
|
9
|
+
column :age, :integer
|
10
|
+
column :avatar, :binary
|
11
|
+
column :created_at, :datetime
|
12
|
+
column :awesome, :boolean
|
13
|
+
column :preferences, :string
|
14
|
+
|
15
|
+
serialize :preferences
|
16
|
+
end
|
data/test/fixtures/customer.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class Customer < ActiveRecord::Base
|
2
2
|
composed_of :address, :mapping => [ %w(address_street street), %w(address_city city), %w(address_country country) ], :allow_nil => true
|
3
|
-
composed_of
|
3
|
+
composed_of(:balance, :class_name => "Money", :mapping => %w(balance amount)) { |balance| balance.to_money }
|
4
4
|
composed_of :gps_location, :allow_nil => true
|
5
5
|
end
|
6
6
|
|
@@ -52,4 +52,4 @@ class GpsLocation
|
|
52
52
|
def ==(other)
|
53
53
|
self.latitude == other.latitude && self.longitude == other.longitude
|
54
54
|
end
|
55
|
-
end
|
55
|
+
end
|
@@ -31,6 +31,7 @@ DROP TABLE defaults;
|
|
31
31
|
DROP TABLE legacy_things;
|
32
32
|
DROP TABLE numeric_data;
|
33
33
|
DROP TABLE mixed_case_monkeys;
|
34
|
+
DROP TABLE minimalistics;
|
34
35
|
|
35
36
|
DROP DOMAIN D_BOOLEAN;
|
36
37
|
|
@@ -60,4 +61,5 @@ DROP GENERATOR keyboards_seq;
|
|
60
61
|
DROP GENERATOR defaults_seq;
|
61
62
|
DROP GENERATOR legacy_things_seq;
|
62
63
|
DROP GENERATOR numeric_data_seq;
|
63
|
-
DROP GENERATOR mixed_case_monkeys_seq;
|
64
|
+
DROP GENERATOR mixed_case_monkeys_seq;
|
65
|
+
DROP GENERATOR minimalistics_seq;
|
@@ -302,3 +302,9 @@ CREATE TABLE mixed_case_monkeys (
|
|
302
302
|
);
|
303
303
|
CREATE GENERATOR mixed_case_monkeys_seq;
|
304
304
|
SET GENERATOR mixed_case_monkeys_seq TO 10000;
|
305
|
+
|
306
|
+
CREATE TABLE minimalistics (
|
307
|
+
id BIGINT NOT NULL
|
308
|
+
);
|
309
|
+
CREATE GENERATOR minimalistics_seq;
|
310
|
+
SET GENERATOR minimalistics_seq TO 10000;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
CREATE TABLE accounts (
|
2
|
-
id integer UNIQUE INDEX DEFAULT _rowid,
|
2
|
+
id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
|
3
3
|
firm_id integer,
|
4
4
|
credit_limit integer
|
5
5
|
)
|
@@ -8,7 +8,7 @@ CREATE PRIMARY KEY accounts (id)
|
|
8
8
|
go
|
9
9
|
|
10
10
|
CREATE TABLE funny_jokes (
|
11
|
-
id integer UNIQUE INDEX DEFAULT _rowid,
|
11
|
+
id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
|
12
12
|
name char(50) DEFAULT NULL
|
13
13
|
)
|
14
14
|
go
|
@@ -16,7 +16,7 @@ CREATE PRIMARY KEY funny_jokes (id)
|
|
16
16
|
go
|
17
17
|
|
18
18
|
CREATE TABLE companies (
|
19
|
-
id integer UNIQUE INDEX DEFAULT _rowid,
|
19
|
+
id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
|
20
20
|
type char(50),
|
21
21
|
ruby_type char(50),
|
22
22
|
firm_id integer,
|
@@ -37,7 +37,7 @@ CREATE TABLE developers_projects (
|
|
37
37
|
go
|
38
38
|
|
39
39
|
CREATE TABLE developers (
|
40
|
-
id integer UNIQUE INDEX DEFAULT _rowid,
|
40
|
+
id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
|
41
41
|
name char(100),
|
42
42
|
salary integer DEFAULT 70000,
|
43
43
|
created_at datetime,
|
@@ -48,7 +48,7 @@ CREATE PRIMARY KEY developers (id)
|
|
48
48
|
go
|
49
49
|
|
50
50
|
CREATE TABLE projects (
|
51
|
-
id integer UNIQUE INDEX DEFAULT _rowid,
|
51
|
+
id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
|
52
52
|
name char(100),
|
53
53
|
type char(255)
|
54
54
|
)
|
@@ -57,7 +57,7 @@ CREATE PRIMARY KEY projects (id)
|
|
57
57
|
go
|
58
58
|
|
59
59
|
CREATE TABLE topics (
|
60
|
-
id integer UNIQUE INDEX DEFAULT _rowid,
|
60
|
+
id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
|
61
61
|
title char(255),
|
62
62
|
author_name char(255),
|
63
63
|
author_email_address char(255),
|
@@ -75,7 +75,7 @@ CREATE PRIMARY KEY topics (id)
|
|
75
75
|
go
|
76
76
|
|
77
77
|
CREATE TABLE customers (
|
78
|
-
id integer UNIQUE INDEX DEFAULT _rowid,
|
78
|
+
id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
|
79
79
|
name char,
|
80
80
|
balance integer default 0,
|
81
81
|
address_street char,
|
@@ -88,7 +88,7 @@ CREATE PRIMARY KEY customers (id)
|
|
88
88
|
go
|
89
89
|
|
90
90
|
CREATE TABLE orders (
|
91
|
-
id integer UNIQUE INDEX DEFAULT _rowid,
|
91
|
+
id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
|
92
92
|
name char,
|
93
93
|
billing_customer_id integer,
|
94
94
|
shipping_customer_id integer
|
@@ -98,7 +98,7 @@ CREATE PRIMARY KEY orders (id)
|
|
98
98
|
go
|
99
99
|
|
100
100
|
CREATE TABLE movies (
|
101
|
-
movieid integer UNIQUE INDEX DEFAULT _rowid,
|
101
|
+
movieid integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
|
102
102
|
name text
|
103
103
|
)
|
104
104
|
go
|
@@ -114,7 +114,7 @@ CREATE PRIMARY KEY subscribers (nick)
|
|
114
114
|
go
|
115
115
|
|
116
116
|
CREATE TABLE booleantests (
|
117
|
-
id integer UNIQUE INDEX DEFAULT _rowid,
|
117
|
+
id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
|
118
118
|
value boolean
|
119
119
|
)
|
120
120
|
go
|
@@ -131,12 +131,17 @@ CREATE TABLE defaults (
|
|
131
131
|
fixed_time timestamp default '2004-01-01 00:00:00.000000-00',
|
132
132
|
char1 char(1) default 'Y',
|
133
133
|
char2 char(50) default 'a char field',
|
134
|
-
char3 text default 'a text field'
|
134
|
+
char3 text default 'a text field',
|
135
|
+
positive_integer integer default 1,
|
136
|
+
negative_integer integer default -1,
|
137
|
+
decimal_number money default 2.78
|
135
138
|
)
|
136
139
|
go
|
140
|
+
CREATE PRIMARY KEY defaults (id)
|
141
|
+
go
|
137
142
|
|
138
143
|
CREATE TABLE auto_id_tests (
|
139
|
-
auto_id integer UNIQUE INDEX DEFAULT _rowid,
|
144
|
+
auto_id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
|
140
145
|
value integer
|
141
146
|
)
|
142
147
|
go
|
@@ -144,20 +149,24 @@ CREATE PRIMARY KEY auto_id_tests (auto_id)
|
|
144
149
|
go
|
145
150
|
|
146
151
|
CREATE TABLE entrants (
|
147
|
-
id integer UNIQUE INDEX
|
148
|
-
name text,
|
149
|
-
course_id integer
|
152
|
+
id integer NOT NULL UNIQUE INDEX,
|
153
|
+
name text NOT NULL,
|
154
|
+
course_id integer NOT NULL
|
150
155
|
)
|
151
156
|
go
|
157
|
+
CREATE PRIMARY KEY entrants (id)
|
158
|
+
go
|
152
159
|
|
153
160
|
CREATE TABLE colnametests (
|
154
161
|
id integer UNIQUE INDEX ,
|
155
162
|
references integer NOT NULL
|
156
163
|
)
|
157
164
|
go
|
165
|
+
CREATE PRIMARY KEY colnametests (id)
|
166
|
+
go
|
158
167
|
|
159
168
|
CREATE TABLE mixins (
|
160
|
-
id integer UNIQUE INDEX DEFAULT _rowid,
|
169
|
+
id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
|
161
170
|
parent_id integer,
|
162
171
|
type char,
|
163
172
|
pos integer,
|
@@ -172,7 +181,7 @@ CREATE PRIMARY KEY mixins (id)
|
|
172
181
|
go
|
173
182
|
|
174
183
|
CREATE TABLE people (
|
175
|
-
id integer UNIQUE INDEX DEFAULT _rowid,
|
184
|
+
id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
|
176
185
|
first_name text,
|
177
186
|
lock_version integer default 0
|
178
187
|
)
|
@@ -181,7 +190,7 @@ CREATE PRIMARY KEY people (id)
|
|
181
190
|
go
|
182
191
|
|
183
192
|
CREATE TABLE readers (
|
184
|
-
id integer UNIQUE INDEX DEFAULT _rowid,
|
193
|
+
id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
|
185
194
|
post_id integer NOT NULL,
|
186
195
|
person_id integer NOT NULL
|
187
196
|
)
|
@@ -190,7 +199,7 @@ CREATE PRIMARY KEY readers (id)
|
|
190
199
|
go
|
191
200
|
|
192
201
|
CREATE TABLE binaries (
|
193
|
-
id integer UNIQUE INDEX DEFAULT _rowid,
|
202
|
+
id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
|
194
203
|
data object
|
195
204
|
)
|
196
205
|
go
|
@@ -228,7 +237,7 @@ CREATE TABLE authors (
|
|
228
237
|
go
|
229
238
|
|
230
239
|
CREATE TABLE tasks (
|
231
|
-
id integer UNIQUE INDEX DEFAULT _rowid,
|
240
|
+
id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
|
232
241
|
starting datetime,
|
233
242
|
ending datetime
|
234
243
|
)
|
@@ -283,11 +292,11 @@ go
|
|
283
292
|
|
284
293
|
CREATE TABLE numeric_data (
|
285
294
|
id INTEGER NOT NULL DEFAULT _rowid,
|
286
|
-
bank_balance
|
287
|
-
big_bank_balance
|
288
|
-
world_population
|
289
|
-
my_house_population
|
290
|
-
decimal_number_with_default
|
295
|
+
bank_balance MONEY,
|
296
|
+
big_bank_balance MONEY,
|
297
|
+
world_population longlong,
|
298
|
+
my_house_population longlong,
|
299
|
+
decimal_number_with_default MONEY DEFAULT 2.78
|
291
300
|
);
|
292
301
|
go
|
293
302
|
CREATE PRIMARY KEY numeric_data (id)
|
@@ -300,3 +309,10 @@ CREATE TABLE mixed_case_monkeys (
|
|
300
309
|
go
|
301
310
|
CREATE PRIMARY KEY mixed_case_monkeys (monkeyID)
|
302
311
|
go
|
312
|
+
|
313
|
+
CREATE TABLE minimalistics (
|
314
|
+
id INTEGER NOT NULL DEFAULT _rowid
|
315
|
+
);
|
316
|
+
go
|
317
|
+
CREATE PRIMARY KEY minimalistics (id)
|
318
|
+
go
|
@@ -31,6 +31,7 @@ drop table keyboards;
|
|
31
31
|
drop table legacy_things;
|
32
32
|
drop table numeric_data;
|
33
33
|
drop table mixed_case_monkeys;
|
34
|
+
drop table minimalistics;
|
34
35
|
|
35
36
|
drop sequence accounts_seq;
|
36
37
|
drop sequence funny_jokes_seq;
|
@@ -63,3 +64,4 @@ drop sequence keyboards_seq;
|
|
63
64
|
drop sequence legacy_things_seq;
|
64
65
|
drop sequence numeric_data_seq;
|
65
66
|
drop sequence mixed_case_monkeys_seq;
|
67
|
+
drop sequence minimalistics_seq;
|
@@ -35,3 +35,10 @@ DROP TABLE legacy_things;
|
|
35
35
|
DROP TABLE numeric_data;
|
36
36
|
DROP TABLE column_data;
|
37
37
|
DROP TABLE mixed_case_monkeys;
|
38
|
+
DROP TABLE postgresql_arrays;
|
39
|
+
DROP TABLE postgresql_moneys;
|
40
|
+
DROP TABLE postgresql_numbers;
|
41
|
+
DROP TABLE postgresql_times;
|
42
|
+
DROP TABLE postgresql_network_addresses;
|
43
|
+
DROP TABLE postgresql_bit_strings;
|
44
|
+
DROP TABLE postgresql_oids;
|
@@ -1,10 +1,9 @@
|
|
1
1
|
CREATE SEQUENCE public.accounts_id_seq START 100;
|
2
2
|
|
3
3
|
CREATE TABLE accounts (
|
4
|
-
id integer DEFAULT nextval('public.accounts_id_seq'),
|
4
|
+
id integer primary key DEFAULT nextval('public.accounts_id_seq'),
|
5
5
|
firm_id integer,
|
6
|
-
credit_limit integer
|
7
|
-
PRIMARY KEY (id)
|
6
|
+
credit_limit integer
|
8
7
|
);
|
9
8
|
|
10
9
|
CREATE TABLE funny_jokes (
|
@@ -15,14 +14,13 @@ CREATE TABLE funny_jokes (
|
|
15
14
|
CREATE SEQUENCE companies_nonstd_seq START 101;
|
16
15
|
|
17
16
|
CREATE TABLE companies (
|
18
|
-
id integer DEFAULT nextval('companies_nonstd_seq'),
|
17
|
+
id integer primary key DEFAULT nextval('companies_nonstd_seq'),
|
19
18
|
"type" character varying(50),
|
20
19
|
"ruby_type" character varying(50),
|
21
20
|
firm_id integer,
|
22
21
|
name character varying(50),
|
23
22
|
client_of integer,
|
24
|
-
rating integer default 1
|
25
|
-
PRIMARY KEY (id)
|
23
|
+
rating integer default 1
|
26
24
|
);
|
27
25
|
|
28
26
|
CREATE TABLE developers_projects (
|
@@ -33,25 +31,23 @@ CREATE TABLE developers_projects (
|
|
33
31
|
);
|
34
32
|
|
35
33
|
CREATE TABLE developers (
|
36
|
-
id serial,
|
34
|
+
id serial primary key,
|
37
35
|
name character varying(100),
|
38
36
|
salary integer DEFAULT 70000,
|
39
37
|
created_at timestamp,
|
40
|
-
updated_at timestamp
|
41
|
-
PRIMARY KEY (id)
|
38
|
+
updated_at timestamp
|
42
39
|
);
|
43
40
|
SELECT setval('developers_id_seq', 100);
|
44
41
|
|
45
42
|
CREATE TABLE projects (
|
46
|
-
id serial,
|
43
|
+
id serial primary key,
|
47
44
|
name character varying(100),
|
48
|
-
type varchar(255)
|
49
|
-
PRIMARY KEY (id)
|
45
|
+
type varchar(255)
|
50
46
|
);
|
51
47
|
SELECT setval('projects_id_seq', 100);
|
52
48
|
|
53
49
|
CREATE TABLE topics (
|
54
|
-
id serial,
|
50
|
+
id serial primary key,
|
55
51
|
title character varying(255),
|
56
52
|
author_name character varying(255),
|
57
53
|
author_email_address character varying(255),
|
@@ -62,52 +58,46 @@ CREATE TABLE topics (
|
|
62
58
|
approved boolean default true,
|
63
59
|
replies_count integer default 0,
|
64
60
|
parent_id integer,
|
65
|
-
"type" character varying(50)
|
66
|
-
PRIMARY KEY (id)
|
61
|
+
"type" character varying(50)
|
67
62
|
);
|
68
63
|
SELECT setval('topics_id_seq', 100);
|
69
64
|
|
70
65
|
CREATE TABLE customers (
|
71
|
-
id serial,
|
66
|
+
id serial primary key,
|
72
67
|
name character varying,
|
73
68
|
balance integer default 0,
|
74
69
|
address_street character varying,
|
75
70
|
address_city character varying,
|
76
71
|
address_country character varying,
|
77
|
-
gps_location character varying
|
78
|
-
PRIMARY KEY (id)
|
72
|
+
gps_location character varying
|
79
73
|
);
|
80
74
|
SELECT setval('customers_id_seq', 100);
|
81
75
|
|
82
76
|
CREATE TABLE orders (
|
83
|
-
id serial,
|
77
|
+
id serial primary key,
|
84
78
|
name character varying,
|
85
79
|
billing_customer_id integer,
|
86
|
-
shipping_customer_id integer
|
87
|
-
PRIMARY KEY (id)
|
80
|
+
shipping_customer_id integer
|
88
81
|
);
|
89
82
|
SELECT setval('orders_id_seq', 100);
|
90
83
|
|
91
84
|
CREATE TABLE movies (
|
92
|
-
movieid serial,
|
93
|
-
name text
|
94
|
-
PRIMARY KEY (movieid)
|
85
|
+
movieid serial primary key,
|
86
|
+
name text
|
95
87
|
);
|
96
88
|
|
97
89
|
CREATE TABLE subscribers (
|
98
|
-
nick text NOT NULL,
|
99
|
-
name text
|
100
|
-
PRIMARY KEY (nick)
|
90
|
+
nick text primary key NOT NULL,
|
91
|
+
name text
|
101
92
|
);
|
102
93
|
|
103
94
|
CREATE TABLE booleantests (
|
104
|
-
id serial,
|
105
|
-
value boolean
|
106
|
-
PRIMARY KEY (id)
|
95
|
+
id serial primary key,
|
96
|
+
value boolean
|
107
97
|
);
|
108
98
|
|
109
99
|
CREATE TABLE defaults (
|
110
|
-
id serial,
|
100
|
+
id serial primary key,
|
111
101
|
modified_date date default CURRENT_DATE,
|
112
102
|
modified_date_function date default now(),
|
113
103
|
fixed_date date default '2004-01-01',
|
@@ -119,28 +109,28 @@ CREATE TABLE defaults (
|
|
119
109
|
char3 text default 'a text field',
|
120
110
|
positive_integer integer default 1,
|
121
111
|
negative_integer integer default -1,
|
122
|
-
decimal_number decimal(3,2) default 2.78
|
112
|
+
decimal_number decimal(3,2) default 2.78,
|
113
|
+
multiline_default text DEFAULT E'--- []\n\n'::text
|
123
114
|
);
|
124
115
|
|
125
116
|
CREATE TABLE auto_id_tests (
|
126
|
-
auto_id serial,
|
127
|
-
value integer
|
128
|
-
PRIMARY KEY (auto_id)
|
117
|
+
auto_id serial primary key,
|
118
|
+
value integer
|
129
119
|
);
|
130
120
|
|
131
121
|
CREATE TABLE entrants (
|
132
|
-
id serial,
|
122
|
+
id serial primary key,
|
133
123
|
name text not null,
|
134
124
|
course_id integer not null
|
135
125
|
);
|
136
126
|
|
137
127
|
CREATE TABLE colnametests (
|
138
|
-
id serial,
|
128
|
+
id serial primary key,
|
139
129
|
"references" integer NOT NULL
|
140
130
|
);
|
141
131
|
|
142
132
|
CREATE TABLE mixins (
|
143
|
-
id serial,
|
133
|
+
id serial primary key,
|
144
134
|
parent_id integer,
|
145
135
|
type character varying,
|
146
136
|
pos integer,
|
@@ -148,38 +138,34 @@ CREATE TABLE mixins (
|
|
148
138
|
rgt integer,
|
149
139
|
root_id integer,
|
150
140
|
created_at timestamp,
|
151
|
-
updated_at timestamp
|
152
|
-
PRIMARY KEY (id)
|
141
|
+
updated_at timestamp
|
153
142
|
);
|
154
143
|
|
155
144
|
CREATE TABLE people (
|
156
|
-
id serial,
|
145
|
+
id serial primary key,
|
157
146
|
first_name text,
|
158
|
-
lock_version integer default 0
|
159
|
-
PRIMARY KEY (id)
|
147
|
+
lock_version integer default 0
|
160
148
|
);
|
161
149
|
|
162
150
|
CREATE TABLE readers (
|
163
|
-
id serial,
|
151
|
+
id serial primary key,
|
164
152
|
post_id integer NOT NULL,
|
165
|
-
person_id integer NOT NULL
|
166
|
-
primary key (id)
|
153
|
+
person_id integer NOT NULL
|
167
154
|
);
|
168
155
|
|
169
|
-
CREATE TABLE binaries (
|
170
|
-
id serial ,
|
171
|
-
data bytea
|
172
|
-
PRIMARY KEY (id)
|
156
|
+
CREATE TABLE binaries (
|
157
|
+
id serial primary key,
|
158
|
+
data bytea
|
173
159
|
);
|
174
160
|
|
175
161
|
CREATE TABLE computers (
|
176
|
-
id serial,
|
162
|
+
id serial primary key,
|
177
163
|
developer integer NOT NULL,
|
178
164
|
"extendedWarranty" integer NOT NULL
|
179
165
|
);
|
180
166
|
|
181
167
|
CREATE TABLE posts (
|
182
|
-
id serial,
|
168
|
+
id serial primary key,
|
183
169
|
author_id integer,
|
184
170
|
title varchar(255),
|
185
171
|
type varchar(255),
|
@@ -187,26 +173,25 @@ CREATE TABLE posts (
|
|
187
173
|
);
|
188
174
|
|
189
175
|
CREATE TABLE comments (
|
190
|
-
id serial,
|
176
|
+
id serial primary key,
|
191
177
|
post_id integer,
|
192
178
|
type varchar(255),
|
193
179
|
body text
|
194
180
|
);
|
195
181
|
|
196
182
|
CREATE TABLE authors (
|
197
|
-
id serial,
|
183
|
+
id serial primary key,
|
198
184
|
name varchar(255) default NULL
|
199
185
|
);
|
200
186
|
|
201
187
|
CREATE TABLE tasks (
|
202
|
-
id serial,
|
188
|
+
id serial primary key,
|
203
189
|
starting timestamp,
|
204
|
-
ending timestamp
|
205
|
-
PRIMARY KEY (id)
|
190
|
+
ending timestamp
|
206
191
|
);
|
207
192
|
|
208
193
|
CREATE TABLE categories (
|
209
|
-
id serial,
|
194
|
+
id serial primary key,
|
210
195
|
name varchar(255),
|
211
196
|
type varchar(255)
|
212
197
|
);
|
@@ -261,3 +246,47 @@ CREATE TABLE mixed_case_monkeys (
|
|
261
246
|
"monkeyID" INTEGER PRIMARY KEY,
|
262
247
|
"fleaCount" INTEGER
|
263
248
|
);
|
249
|
+
|
250
|
+
CREATE TABLE postgresql_arrays (
|
251
|
+
id SERIAL PRIMARY KEY,
|
252
|
+
commission_by_quarter INTEGER[],
|
253
|
+
nicknames TEXT[]
|
254
|
+
);
|
255
|
+
|
256
|
+
CREATE TABLE postgresql_moneys (
|
257
|
+
id SERIAL PRIMARY KEY,
|
258
|
+
wealth MONEY
|
259
|
+
);
|
260
|
+
|
261
|
+
CREATE TABLE postgresql_numbers (
|
262
|
+
id SERIAL PRIMARY KEY,
|
263
|
+
single REAL,
|
264
|
+
double DOUBLE PRECISION
|
265
|
+
);
|
266
|
+
|
267
|
+
CREATE TABLE postgresql_times (
|
268
|
+
id SERIAL PRIMARY KEY,
|
269
|
+
time_interval INTERVAL
|
270
|
+
);
|
271
|
+
|
272
|
+
CREATE TABLE postgresql_network_addresses (
|
273
|
+
id SERIAL PRIMARY KEY,
|
274
|
+
cidr_address CIDR,
|
275
|
+
inet_address INET,
|
276
|
+
mac_address MACADDR
|
277
|
+
);
|
278
|
+
|
279
|
+
CREATE TABLE postgresql_bit_strings (
|
280
|
+
id SERIAL PRIMARY KEY,
|
281
|
+
bit_string BIT(8),
|
282
|
+
bit_string_varying BIT VARYING(8)
|
283
|
+
);
|
284
|
+
|
285
|
+
CREATE TABLE postgresql_oids (
|
286
|
+
id SERIAL PRIMARY KEY,
|
287
|
+
obj_id OID
|
288
|
+
);
|
289
|
+
|
290
|
+
CREATE TABLE minimalistics (
|
291
|
+
id serial primary key
|
292
|
+
);
|