activerecord 2.0.5 → 2.1.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 +168 -6
- data/README +27 -22
- data/RUNNING_UNIT_TESTS +7 -4
- data/Rakefile +22 -25
- data/lib/active_record.rb +8 -2
- data/lib/active_record/aggregations.rb +21 -12
- data/lib/active_record/association_preload.rb +277 -0
- data/lib/active_record/associations.rb +481 -295
- data/lib/active_record/associations/association_collection.rb +162 -37
- data/lib/active_record/associations/association_proxy.rb +71 -7
- data/lib/active_record/associations/belongs_to_association.rb +5 -3
- data/lib/active_record/associations/belongs_to_polymorphic_association.rb +5 -6
- data/lib/active_record/associations/has_and_belongs_to_many_association.rb +12 -64
- data/lib/active_record/associations/has_many_association.rb +8 -73
- data/lib/active_record/associations/has_many_through_association.rb +68 -117
- data/lib/active_record/associations/has_one_association.rb +7 -5
- data/lib/active_record/associations/has_one_through_association.rb +28 -0
- data/lib/active_record/attribute_methods.rb +69 -19
- data/lib/active_record/base.rb +496 -275
- data/lib/active_record/calculations.rb +28 -21
- data/lib/active_record/callbacks.rb +9 -38
- data/lib/active_record/connection_adapters/abstract/connection_specification.rb +3 -2
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +2 -2
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +6 -0
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +232 -45
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +141 -27
- data/lib/active_record/connection_adapters/abstract_adapter.rb +9 -13
- data/lib/active_record/connection_adapters/mysql_adapter.rb +57 -24
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +143 -42
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +1 -1
- data/lib/active_record/connection_adapters/sqlite_adapter.rb +18 -10
- data/lib/active_record/dirty.rb +158 -0
- data/lib/active_record/fixtures.rb +121 -156
- data/lib/active_record/locking/optimistic.rb +14 -11
- data/lib/active_record/locking/pessimistic.rb +2 -2
- data/lib/active_record/migration.rb +157 -77
- data/lib/active_record/named_scope.rb +163 -0
- data/lib/active_record/observer.rb +19 -5
- data/lib/active_record/reflection.rb +34 -14
- data/lib/active_record/schema.rb +7 -14
- data/lib/active_record/schema_dumper.rb +4 -4
- data/lib/active_record/serialization.rb +5 -5
- data/lib/active_record/serializers/json_serializer.rb +37 -28
- data/lib/active_record/serializers/xml_serializer.rb +52 -29
- data/lib/active_record/test_case.rb +36 -0
- data/lib/active_record/timestamp.rb +4 -4
- data/lib/active_record/transactions.rb +3 -3
- data/lib/active_record/validations.rb +182 -248
- data/lib/active_record/version.rb +2 -2
- data/test/{fixtures → assets}/example.log +0 -0
- data/test/{fixtures → assets}/flowers.jpg +0 -0
- data/test/cases/aaa_create_tables_test.rb +24 -0
- data/test/cases/active_schema_test_mysql.rb +95 -0
- data/test/cases/active_schema_test_postgresql.rb +24 -0
- data/test/{adapter_test.rb → cases/adapter_test.rb} +15 -14
- data/test/{adapter_test_sqlserver.rb → cases/adapter_test_sqlserver.rb} +95 -95
- data/test/{aggregations_test.rb → cases/aggregations_test.rb} +20 -20
- data/test/{ar_schema_test.rb → cases/ar_schema_test.rb} +6 -6
- data/test/cases/associations/belongs_to_associations_test.rb +412 -0
- data/test/{associations → cases/associations}/callbacks_test.rb +24 -10
- data/test/{associations → cases/associations}/cascaded_eager_loading_test.rb +18 -17
- data/test/cases/associations/eager_load_nested_include_test.rb +83 -0
- data/test/{associations → cases/associations}/eager_singularization_test.rb +5 -5
- data/test/{associations → cases/associations}/eager_test.rb +216 -51
- data/test/{associations → cases/associations}/extension_test.rb +8 -8
- data/test/cases/associations/has_and_belongs_to_many_associations_test.rb +684 -0
- data/test/cases/associations/has_many_associations_test.rb +932 -0
- data/test/cases/associations/has_many_through_associations_test.rb +190 -0
- data/test/cases/associations/has_one_associations_test.rb +323 -0
- data/test/cases/associations/has_one_through_associations_test.rb +74 -0
- data/test/{associations → cases/associations}/inner_join_association_test.rb +20 -20
- data/test/{associations → cases/associations}/join_model_test.rb +175 -35
- data/test/cases/associations_test.rb +262 -0
- data/test/{attribute_methods_test.rb → cases/attribute_methods_test.rb} +103 -11
- data/test/{base_test.rb → cases/base_test.rb} +338 -191
- data/test/{binary_test.rb → cases/binary_test.rb} +6 -4
- data/test/{calculations_test.rb → cases/calculations_test.rb} +35 -23
- data/test/{callbacks_test.rb → cases/callbacks_test.rb} +7 -7
- data/test/{class_inheritable_attributes_test.rb → cases/class_inheritable_attributes_test.rb} +3 -3
- data/test/{column_alias_test.rb → cases/column_alias_test.rb} +3 -3
- data/test/{connection_test_firebird.rb → cases/connection_test_firebird.rb} +2 -2
- data/test/{connection_test_mysql.rb → cases/connection_test_mysql.rb} +2 -2
- data/test/{copy_table_test_sqlite.rb → cases/copy_table_test_sqlite.rb} +13 -13
- data/test/{datatype_test_postgresql.rb → cases/datatype_test_postgresql.rb} +8 -8
- data/test/{date_time_test.rb → cases/date_time_test.rb} +5 -5
- data/test/{default_test_firebird.rb → cases/default_test_firebird.rb} +3 -3
- data/test/{defaults_test.rb → cases/defaults_test.rb} +8 -6
- data/test/{deprecated_finder_test.rb → cases/deprecated_finder_test.rb} +3 -3
- data/test/cases/dirty_test.rb +163 -0
- data/test/cases/finder_respond_to_test.rb +76 -0
- data/test/{finder_test.rb → cases/finder_test.rb} +266 -33
- data/test/{fixtures_test.rb → cases/fixtures_test.rb} +88 -72
- data/test/cases/helper.rb +47 -0
- data/test/{inheritance_test.rb → cases/inheritance_test.rb} +61 -17
- data/test/cases/invalid_date_test.rb +24 -0
- data/test/{json_serialization_test.rb → cases/json_serialization_test.rb} +36 -11
- data/test/{lifecycle_test.rb → cases/lifecycle_test.rb} +16 -13
- data/test/{locking_test.rb → cases/locking_test.rb} +17 -10
- data/test/{method_scoping_test.rb → cases/method_scoping_test.rb} +75 -39
- data/test/{migration_test.rb → cases/migration_test.rb} +420 -80
- data/test/{migration_test_firebird.rb → cases/migration_test_firebird.rb} +3 -3
- data/test/{mixin_test.rb → cases/mixin_test.rb} +7 -6
- data/test/{modules_test.rb → cases/modules_test.rb} +11 -6
- data/test/{multiple_db_test.rb → cases/multiple_db_test.rb} +5 -5
- data/test/cases/named_scope_test.rb +157 -0
- data/test/{pk_test.rb → cases/pk_test.rb} +10 -10
- data/test/{query_cache_test.rb → cases/query_cache_test.rb} +12 -10
- data/test/{readonly_test.rb → cases/readonly_test.rb} +11 -11
- data/test/{reflection_test.rb → cases/reflection_test.rb} +15 -14
- data/test/{reserved_word_test_mysql.rb → cases/reserved_word_test_mysql.rb} +4 -5
- data/test/{schema_authorization_test_postgresql.rb → cases/schema_authorization_test_postgresql.rb} +5 -5
- data/test/cases/schema_dumper_test.rb +138 -0
- data/test/cases/schema_test_postgresql.rb +102 -0
- data/test/{serialization_test.rb → cases/serialization_test.rb} +7 -7
- data/test/{synonym_test_oracle.rb → cases/synonym_test_oracle.rb} +5 -5
- data/test/{table_name_test_sqlserver.rb → cases/table_name_test_sqlserver.rb} +3 -3
- data/test/{threaded_connections_test.rb → cases/threaded_connections_test.rb} +7 -7
- data/test/{transactions_test.rb → cases/transactions_test.rb} +31 -5
- data/test/{unconnected_test.rb → cases/unconnected_test.rb} +2 -2
- data/test/{validations_test.rb → cases/validations_test.rb} +141 -39
- data/test/{xml_serialization_test.rb → cases/xml_serialization_test.rb} +12 -12
- data/test/config.rb +5 -0
- data/test/connections/native_db2/connection.rb +1 -1
- data/test/connections/native_firebird/connection.rb +1 -1
- data/test/connections/native_frontbase/connection.rb +1 -1
- data/test/connections/native_mysql/connection.rb +1 -1
- data/test/connections/native_openbase/connection.rb +1 -1
- data/test/connections/native_oracle/connection.rb +1 -1
- data/test/connections/native_postgresql/connection.rb +1 -3
- data/test/connections/native_sqlite/connection.rb +2 -2
- data/test/connections/native_sqlite3/connection.rb +2 -2
- data/test/connections/native_sqlite3/in_memory_connection.rb +3 -3
- data/test/connections/native_sybase/connection.rb +1 -1
- data/test/fixtures/author_addresses.yml +5 -0
- data/test/fixtures/authors.yml +2 -0
- data/test/fixtures/clubs.yml +6 -0
- data/test/fixtures/jobs.yml +7 -0
- data/test/fixtures/members.yml +4 -0
- data/test/fixtures/memberships.yml +20 -0
- data/test/fixtures/owners.yml +7 -0
- data/test/fixtures/people.yml +4 -1
- data/test/fixtures/pets.yml +14 -0
- data/test/fixtures/posts.yml +1 -0
- data/test/fixtures/price_estimates.yml +7 -0
- data/test/fixtures/readers.yml +5 -0
- data/test/fixtures/references.yml +17 -0
- data/test/fixtures/sponsors.yml +9 -0
- data/test/fixtures/subscribers.yml +7 -0
- data/test/fixtures/subscriptions.yml +12 -0
- data/test/fixtures/taggings.yml +4 -1
- data/test/fixtures/topics.yml +22 -2
- data/test/fixtures/warehouse-things.yml +3 -0
- data/test/{fixtures/migrations_with_decimal → migrations/decimal}/1_give_me_big_numbers.rb +0 -0
- data/test/{fixtures/migrations_with_duplicate → migrations/duplicate}/1_people_have_last_names.rb +1 -1
- data/test/{fixtures/migrations_with_duplicate → migrations/duplicate}/2_we_need_reminders.rb +1 -1
- data/test/{fixtures/migrations_with_duplicate → migrations/duplicate}/3_foo.rb +0 -0
- data/test/{fixtures/migrations → migrations/duplicate}/3_innocent_jointable.rb +0 -0
- data/test/migrations/duplicate_names/20080507052938_chunky.rb +7 -0
- data/test/migrations/duplicate_names/20080507053028_chunky.rb +7 -0
- data/test/{fixtures/migrations_with_duplicate → migrations/interleaved/pass_1}/3_innocent_jointable.rb +0 -0
- data/test/{fixtures/migrations → migrations/interleaved/pass_2}/1_people_have_last_names.rb +1 -1
- data/test/{fixtures/migrations_with_missing_versions/4_innocent_jointable.rb → migrations/interleaved/pass_2/3_innocent_jointable.rb} +0 -0
- data/test/{fixtures/migrations_with_missing_versions → migrations/interleaved/pass_3}/1_people_have_last_names.rb +1 -1
- data/test/migrations/interleaved/pass_3/2_i_raise_on_down.rb +8 -0
- data/test/migrations/interleaved/pass_3/3_innocent_jointable.rb +12 -0
- data/test/{fixtures/migrations_with_missing_versions → migrations/missing}/1000_people_have_middle_names.rb +1 -1
- data/test/migrations/missing/1_people_have_last_names.rb +9 -0
- data/test/{fixtures/migrations_with_missing_versions → migrations/missing}/3_we_need_reminders.rb +1 -1
- data/test/migrations/missing/4_innocent_jointable.rb +12 -0
- data/test/migrations/valid/1_people_have_last_names.rb +9 -0
- data/test/{fixtures/migrations → migrations/valid}/2_we_need_reminders.rb +1 -1
- data/test/migrations/valid/3_innocent_jointable.rb +12 -0
- data/test/{fixtures → models}/author.rb +28 -4
- data/test/{fixtures → models}/auto_id.rb +0 -0
- data/test/{fixtures → models}/binary.rb +0 -0
- data/test/{fixtures → models}/book.rb +0 -0
- data/test/{fixtures → models}/categorization.rb +0 -0
- data/test/{fixtures → models}/category.rb +8 -5
- data/test/{fixtures → models}/citation.rb +0 -0
- data/test/models/club.rb +7 -0
- data/test/{fixtures → models}/column_name.rb +0 -0
- data/test/{fixtures → models}/comment.rb +5 -3
- data/test/{fixtures → models}/company.rb +15 -6
- data/test/{fixtures → models}/company_in_module.rb +5 -3
- data/test/{fixtures → models}/computer.rb +0 -1
- data/test/{fixtures → models}/contact.rb +1 -1
- data/test/{fixtures → models}/course.rb +0 -0
- data/test/{fixtures → models}/customer.rb +8 -8
- data/test/{fixtures → models}/default.rb +0 -0
- data/test/{fixtures → models}/developer.rb +14 -10
- data/test/{fixtures → models}/edge.rb +0 -0
- data/test/{fixtures → models}/entrant.rb +0 -0
- data/test/models/guid.rb +2 -0
- data/test/{fixtures → models}/item.rb +0 -0
- data/test/models/job.rb +5 -0
- data/test/{fixtures → models}/joke.rb +0 -0
- data/test/{fixtures → models}/keyboard.rb +0 -0
- data/test/{fixtures → models}/legacy_thing.rb +0 -0
- data/test/{fixtures → models}/matey.rb +0 -0
- data/test/models/member.rb +9 -0
- data/test/models/membership.rb +9 -0
- data/test/{fixtures → models}/minimalistic.rb +0 -0
- data/test/{fixtures → models}/mixed_case_monkey.rb +0 -0
- data/test/{fixtures → models}/movie.rb +0 -0
- data/test/{fixtures → models}/order.rb +2 -2
- data/test/models/owner.rb +4 -0
- data/test/{fixtures → models}/parrot.rb +0 -0
- data/test/models/person.rb +10 -0
- data/test/models/pet.rb +4 -0
- data/test/models/pirate.rb +9 -0
- data/test/{fixtures → models}/post.rb +23 -2
- data/test/models/price_estimate.rb +3 -0
- data/test/{fixtures → models}/project.rb +1 -0
- data/test/{fixtures → models}/reader.rb +0 -0
- data/test/models/reference.rb +4 -0
- data/test/{fixtures → models}/reply.rb +7 -5
- data/test/{fixtures → models}/ship.rb +0 -0
- data/test/models/sponsor.rb +4 -0
- data/test/{fixtures → models}/subject.rb +0 -0
- data/test/{fixtures → models}/subscriber.rb +2 -0
- data/test/models/subscription.rb +4 -0
- data/test/{fixtures → models}/tag.rb +0 -0
- data/test/{fixtures → models}/tagging.rb +0 -0
- data/test/{fixtures → models}/task.rb +0 -0
- data/test/{fixtures → models}/topic.rb +32 -4
- data/test/{fixtures → models}/treasure.rb +2 -0
- data/test/{fixtures → models}/vertex.rb +0 -0
- data/test/models/warehouse_thing.rb +5 -0
- data/test/schema/mysql_specific_schema.rb +12 -0
- data/test/schema/postgresql_specific_schema.rb +103 -0
- data/test/schema/schema.rb +421 -0
- data/test/schema/schema2.rb +6 -0
- data/test/schema/sqlite_specific_schema.rb +25 -0
- data/test/schema/sqlserver_specific_schema.rb +5 -0
- metadata +192 -176
- data/test/aaa_create_tables_test.rb +0 -72
- data/test/abstract_unit.rb +0 -84
- data/test/active_schema_test_mysql.rb +0 -46
- data/test/all.sh +0 -8
- data/test/association_inheritance_reload.rb +0 -14
- data/test/associations_test.rb +0 -2177
- data/test/fixtures/bad_fixtures/attr_with_numeric_first_char +0 -1
- data/test/fixtures/bad_fixtures/attr_with_spaces +0 -1
- data/test/fixtures/bad_fixtures/blank_line +0 -3
- data/test/fixtures/bad_fixtures/duplicate_attributes +0 -3
- data/test/fixtures/bad_fixtures/missing_value +0 -1
- data/test/fixtures/db_definitions/db2.drop.sql +0 -33
- data/test/fixtures/db_definitions/db2.sql +0 -235
- data/test/fixtures/db_definitions/db22.drop.sql +0 -2
- data/test/fixtures/db_definitions/db22.sql +0 -5
- data/test/fixtures/db_definitions/firebird.drop.sql +0 -65
- data/test/fixtures/db_definitions/firebird.sql +0 -310
- data/test/fixtures/db_definitions/firebird2.drop.sql +0 -2
- data/test/fixtures/db_definitions/firebird2.sql +0 -6
- data/test/fixtures/db_definitions/frontbase.drop.sql +0 -33
- data/test/fixtures/db_definitions/frontbase.sql +0 -273
- data/test/fixtures/db_definitions/frontbase2.drop.sql +0 -1
- data/test/fixtures/db_definitions/frontbase2.sql +0 -4
- data/test/fixtures/db_definitions/openbase.drop.sql +0 -2
- data/test/fixtures/db_definitions/openbase.sql +0 -318
- data/test/fixtures/db_definitions/openbase2.drop.sql +0 -2
- data/test/fixtures/db_definitions/openbase2.sql +0 -7
- data/test/fixtures/db_definitions/oracle.drop.sql +0 -67
- data/test/fixtures/db_definitions/oracle.sql +0 -330
- data/test/fixtures/db_definitions/oracle2.drop.sql +0 -2
- data/test/fixtures/db_definitions/oracle2.sql +0 -6
- data/test/fixtures/db_definitions/postgresql.drop.sql +0 -44
- data/test/fixtures/db_definitions/postgresql.sql +0 -292
- data/test/fixtures/db_definitions/postgresql2.drop.sql +0 -2
- data/test/fixtures/db_definitions/postgresql2.sql +0 -4
- data/test/fixtures/db_definitions/schema.rb +0 -354
- data/test/fixtures/db_definitions/schema2.rb +0 -11
- data/test/fixtures/db_definitions/sqlite.drop.sql +0 -33
- data/test/fixtures/db_definitions/sqlite.sql +0 -219
- data/test/fixtures/db_definitions/sqlite2.drop.sql +0 -2
- data/test/fixtures/db_definitions/sqlite2.sql +0 -5
- data/test/fixtures/db_definitions/sybase.drop.sql +0 -35
- data/test/fixtures/db_definitions/sybase.sql +0 -222
- data/test/fixtures/db_definitions/sybase2.drop.sql +0 -4
- data/test/fixtures/db_definitions/sybase2.sql +0 -5
- data/test/fixtures/developers_projects/david_action_controller +0 -3
- data/test/fixtures/developers_projects/david_active_record +0 -3
- data/test/fixtures/developers_projects/jamis_active_record +0 -2
- data/test/fixtures/person.rb +0 -4
- data/test/fixtures/pirate.rb +0 -5
- data/test/fixtures/subscribers/first +0 -2
- data/test/fixtures/subscribers/second +0 -2
- data/test/schema_dumper_test.rb +0 -131
- data/test/schema_test_postgresql.rb +0 -64
@@ -1,292 +0,0 @@
|
|
1
|
-
CREATE SEQUENCE public.accounts_id_seq START 100;
|
2
|
-
|
3
|
-
CREATE TABLE accounts (
|
4
|
-
id integer primary key DEFAULT nextval('public.accounts_id_seq'),
|
5
|
-
firm_id integer,
|
6
|
-
credit_limit integer
|
7
|
-
);
|
8
|
-
|
9
|
-
CREATE TABLE funny_jokes (
|
10
|
-
id serial,
|
11
|
-
name character varying(50)
|
12
|
-
);
|
13
|
-
|
14
|
-
CREATE SEQUENCE companies_nonstd_seq START 101;
|
15
|
-
|
16
|
-
CREATE TABLE companies (
|
17
|
-
id integer primary key DEFAULT nextval('companies_nonstd_seq'),
|
18
|
-
"type" character varying(50),
|
19
|
-
"ruby_type" character varying(50),
|
20
|
-
firm_id integer,
|
21
|
-
name character varying(50),
|
22
|
-
client_of integer,
|
23
|
-
rating integer default 1
|
24
|
-
);
|
25
|
-
|
26
|
-
CREATE TABLE developers_projects (
|
27
|
-
developer_id integer NOT NULL,
|
28
|
-
project_id integer NOT NULL,
|
29
|
-
joined_on date,
|
30
|
-
access_level integer default 1
|
31
|
-
);
|
32
|
-
|
33
|
-
CREATE TABLE developers (
|
34
|
-
id serial primary key,
|
35
|
-
name character varying(100),
|
36
|
-
salary integer DEFAULT 70000,
|
37
|
-
created_at timestamp,
|
38
|
-
updated_at timestamp
|
39
|
-
);
|
40
|
-
SELECT setval('developers_id_seq', 100);
|
41
|
-
|
42
|
-
CREATE TABLE projects (
|
43
|
-
id serial primary key,
|
44
|
-
name character varying(100),
|
45
|
-
type varchar(255)
|
46
|
-
);
|
47
|
-
SELECT setval('projects_id_seq', 100);
|
48
|
-
|
49
|
-
CREATE TABLE topics (
|
50
|
-
id serial primary key,
|
51
|
-
title character varying(255),
|
52
|
-
author_name character varying(255),
|
53
|
-
author_email_address character varying(255),
|
54
|
-
written_on timestamp without time zone,
|
55
|
-
bonus_time time,
|
56
|
-
last_read date,
|
57
|
-
content text,
|
58
|
-
approved boolean default true,
|
59
|
-
replies_count integer default 0,
|
60
|
-
parent_id integer,
|
61
|
-
"type" character varying(50)
|
62
|
-
);
|
63
|
-
SELECT setval('topics_id_seq', 100);
|
64
|
-
|
65
|
-
CREATE TABLE customers (
|
66
|
-
id serial primary key,
|
67
|
-
name character varying,
|
68
|
-
balance integer default 0,
|
69
|
-
address_street character varying,
|
70
|
-
address_city character varying,
|
71
|
-
address_country character varying,
|
72
|
-
gps_location character varying
|
73
|
-
);
|
74
|
-
SELECT setval('customers_id_seq', 100);
|
75
|
-
|
76
|
-
CREATE TABLE orders (
|
77
|
-
id serial primary key,
|
78
|
-
name character varying,
|
79
|
-
billing_customer_id integer,
|
80
|
-
shipping_customer_id integer
|
81
|
-
);
|
82
|
-
SELECT setval('orders_id_seq', 100);
|
83
|
-
|
84
|
-
CREATE TABLE movies (
|
85
|
-
movieid serial primary key,
|
86
|
-
name text
|
87
|
-
);
|
88
|
-
|
89
|
-
CREATE TABLE subscribers (
|
90
|
-
nick text primary key NOT NULL,
|
91
|
-
name text
|
92
|
-
);
|
93
|
-
|
94
|
-
CREATE TABLE booleantests (
|
95
|
-
id serial primary key,
|
96
|
-
value boolean
|
97
|
-
);
|
98
|
-
|
99
|
-
CREATE TABLE defaults (
|
100
|
-
id serial primary key,
|
101
|
-
modified_date date default CURRENT_DATE,
|
102
|
-
modified_date_function date default now(),
|
103
|
-
fixed_date date default '2004-01-01',
|
104
|
-
modified_time timestamp default CURRENT_TIMESTAMP,
|
105
|
-
modified_time_function timestamp default now(),
|
106
|
-
fixed_time timestamp default '2004-01-01 00:00:00.000000-00',
|
107
|
-
char1 char(1) default 'Y',
|
108
|
-
char2 character varying(50) default 'a varchar field',
|
109
|
-
char3 text default 'a text field',
|
110
|
-
positive_integer integer default 1,
|
111
|
-
negative_integer integer default -1,
|
112
|
-
decimal_number decimal(3,2) default 2.78,
|
113
|
-
multiline_default text DEFAULT E'--- []\n\n'::text
|
114
|
-
);
|
115
|
-
|
116
|
-
CREATE TABLE auto_id_tests (
|
117
|
-
auto_id serial primary key,
|
118
|
-
value integer
|
119
|
-
);
|
120
|
-
|
121
|
-
CREATE TABLE entrants (
|
122
|
-
id serial primary key,
|
123
|
-
name text not null,
|
124
|
-
course_id integer not null
|
125
|
-
);
|
126
|
-
|
127
|
-
CREATE TABLE colnametests (
|
128
|
-
id serial primary key,
|
129
|
-
"references" integer NOT NULL
|
130
|
-
);
|
131
|
-
|
132
|
-
CREATE TABLE mixins (
|
133
|
-
id serial primary key,
|
134
|
-
parent_id integer,
|
135
|
-
type character varying,
|
136
|
-
pos integer,
|
137
|
-
lft integer,
|
138
|
-
rgt integer,
|
139
|
-
root_id integer,
|
140
|
-
created_at timestamp,
|
141
|
-
updated_at timestamp
|
142
|
-
);
|
143
|
-
|
144
|
-
CREATE TABLE people (
|
145
|
-
id serial primary key,
|
146
|
-
first_name text,
|
147
|
-
lock_version integer default 0
|
148
|
-
);
|
149
|
-
|
150
|
-
CREATE TABLE readers (
|
151
|
-
id serial primary key,
|
152
|
-
post_id integer NOT NULL,
|
153
|
-
person_id integer NOT NULL
|
154
|
-
);
|
155
|
-
|
156
|
-
CREATE TABLE binaries (
|
157
|
-
id serial primary key,
|
158
|
-
data bytea
|
159
|
-
);
|
160
|
-
|
161
|
-
CREATE TABLE computers (
|
162
|
-
id serial primary key,
|
163
|
-
developer integer NOT NULL,
|
164
|
-
"extendedWarranty" integer NOT NULL
|
165
|
-
);
|
166
|
-
|
167
|
-
CREATE TABLE posts (
|
168
|
-
id serial primary key,
|
169
|
-
author_id integer,
|
170
|
-
title varchar(255),
|
171
|
-
type varchar(255),
|
172
|
-
body text
|
173
|
-
);
|
174
|
-
|
175
|
-
CREATE TABLE comments (
|
176
|
-
id serial primary key,
|
177
|
-
post_id integer,
|
178
|
-
type varchar(255),
|
179
|
-
body text
|
180
|
-
);
|
181
|
-
|
182
|
-
CREATE TABLE authors (
|
183
|
-
id serial primary key,
|
184
|
-
name varchar(255) default NULL
|
185
|
-
);
|
186
|
-
|
187
|
-
CREATE TABLE tasks (
|
188
|
-
id serial primary key,
|
189
|
-
starting timestamp,
|
190
|
-
ending timestamp
|
191
|
-
);
|
192
|
-
|
193
|
-
CREATE TABLE categories (
|
194
|
-
id serial primary key,
|
195
|
-
name varchar(255),
|
196
|
-
type varchar(255)
|
197
|
-
);
|
198
|
-
|
199
|
-
CREATE TABLE categories_posts (
|
200
|
-
category_id integer NOT NULL,
|
201
|
-
post_id integer NOT NULL
|
202
|
-
);
|
203
|
-
|
204
|
-
CREATE TABLE fk_test_has_pk (
|
205
|
-
id INTEGER NOT NULL PRIMARY KEY
|
206
|
-
);
|
207
|
-
|
208
|
-
CREATE TABLE fk_test_has_fk (
|
209
|
-
id INTEGER NOT NULL PRIMARY KEY,
|
210
|
-
fk_id INTEGER NOT NULL REFERENCES fk_test_has_fk(id)
|
211
|
-
);
|
212
|
-
|
213
|
-
CREATE TABLE geometrics (
|
214
|
-
id serial primary key,
|
215
|
-
a_point point,
|
216
|
-
-- a_line line, (the line type is currently not implemented in postgresql)
|
217
|
-
a_line_segment lseg,
|
218
|
-
a_box box,
|
219
|
-
a_path path,
|
220
|
-
a_polygon polygon,
|
221
|
-
a_circle circle
|
222
|
-
);
|
223
|
-
|
224
|
-
CREATE TABLE keyboards (
|
225
|
-
key_number serial primary key,
|
226
|
-
"name" character varying(50)
|
227
|
-
);
|
228
|
-
|
229
|
-
--Altered lock_version column name.
|
230
|
-
CREATE TABLE legacy_things (
|
231
|
-
id serial primary key,
|
232
|
-
tps_report_number integer,
|
233
|
-
version integer default 0
|
234
|
-
);
|
235
|
-
|
236
|
-
CREATE TABLE numeric_data (
|
237
|
-
id serial primary key,
|
238
|
-
bank_balance decimal(10,2),
|
239
|
-
big_bank_balance decimal(15,2),
|
240
|
-
world_population decimal(10),
|
241
|
-
my_house_population decimal(2),
|
242
|
-
decimal_number_with_default decimal(3,2) default 2.78
|
243
|
-
);
|
244
|
-
|
245
|
-
CREATE TABLE mixed_case_monkeys (
|
246
|
-
"monkeyID" INTEGER PRIMARY KEY,
|
247
|
-
"fleaCount" INTEGER
|
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
|
-
);
|
@@ -1,354 +0,0 @@
|
|
1
|
-
ActiveRecord::Schema.define do
|
2
|
-
|
3
|
-
# adapter name is checked because we are under a transition of
|
4
|
-
# moving the sql files under activerecord/test/fixtures/db_definitions
|
5
|
-
# to this file, schema.rb.
|
6
|
-
if adapter_name == "MySQL"
|
7
|
-
|
8
|
-
# Please keep these create table statements in alphabetical order
|
9
|
-
# unless the ordering matters. In which case, define them below
|
10
|
-
create_table :accounts, :force => true do |t|
|
11
|
-
t.integer :firm_id
|
12
|
-
t.integer :credit_limit
|
13
|
-
end
|
14
|
-
|
15
|
-
create_table :authors, :force => true do |t|
|
16
|
-
t.string :name, :null => false
|
17
|
-
end
|
18
|
-
|
19
|
-
create_table :auto_id_tests, :force => true, :id => false do |t|
|
20
|
-
t.primary_key :auto_id
|
21
|
-
t.integer :value
|
22
|
-
end
|
23
|
-
|
24
|
-
create_table :binaries, :force => true do |t|
|
25
|
-
t.binary :data
|
26
|
-
end
|
27
|
-
|
28
|
-
create_table :booleantests, :force => true do |t|
|
29
|
-
t.integer :value
|
30
|
-
end
|
31
|
-
|
32
|
-
create_table :categories, :force => true do |t|
|
33
|
-
t.string :name, :null => false
|
34
|
-
t.string :type
|
35
|
-
end
|
36
|
-
|
37
|
-
create_table :categories_posts, :force => true, :id => false do |t|
|
38
|
-
t.integer :category_id, :null => false
|
39
|
-
t.integer :post_id, :null => false
|
40
|
-
end
|
41
|
-
|
42
|
-
create_table :colnametests, :force => true do |t|
|
43
|
-
t.integer :references, :null => false
|
44
|
-
end
|
45
|
-
|
46
|
-
create_table :comments, :force => true do |t|
|
47
|
-
t.integer :post_id, :null => false
|
48
|
-
t.text :body, :null => false
|
49
|
-
t.string :type
|
50
|
-
end
|
51
|
-
|
52
|
-
create_table :companies, :force => true do |t|
|
53
|
-
t.string :type
|
54
|
-
t.string :ruby_type
|
55
|
-
t.integer :firm_id
|
56
|
-
t.string :name
|
57
|
-
t.integer :client_of
|
58
|
-
t.integer :rating, :default => 1
|
59
|
-
end
|
60
|
-
|
61
|
-
create_table :computers, :force => true do |t|
|
62
|
-
t.integer :developer, :null => false
|
63
|
-
t.integer :extendedWarranty, :null => false
|
64
|
-
end
|
65
|
-
|
66
|
-
|
67
|
-
create_table :customers, :force => true do |t|
|
68
|
-
t.string :name
|
69
|
-
t.integer :balance, :default => 0
|
70
|
-
t.string :address_street
|
71
|
-
t.string :address_city
|
72
|
-
t.string :address_country
|
73
|
-
t.string :gps_location
|
74
|
-
end
|
75
|
-
|
76
|
-
create_table :developers, :force => true do |t|
|
77
|
-
t.string :name
|
78
|
-
t.integer :salary, :default => 70000
|
79
|
-
t.datetime :created_at
|
80
|
-
t.datetime :updated_at
|
81
|
-
end
|
82
|
-
|
83
|
-
create_table :developers_projects, :force => true, :id => false do |t|
|
84
|
-
t.integer :developer_id, :null => false
|
85
|
-
t.integer :project_id, :null => false
|
86
|
-
t.date :joined_on
|
87
|
-
t.integer :access_level, :default => 1
|
88
|
-
end
|
89
|
-
|
90
|
-
create_table :entrants, :force => true do |t|
|
91
|
-
t.string :name, :null => false
|
92
|
-
t.integer :course_id, :null => false
|
93
|
-
end
|
94
|
-
|
95
|
-
create_table :funny_jokes, :force => true do |t|
|
96
|
-
t.string :name
|
97
|
-
end
|
98
|
-
|
99
|
-
create_table :keyboards, :force => true, :id => false do |t|
|
100
|
-
t.primary_key :key_number
|
101
|
-
t.string :name
|
102
|
-
end
|
103
|
-
|
104
|
-
create_table :legacy_things, :force => true do |t|
|
105
|
-
t.integer :tps_report_number
|
106
|
-
t.integer :version, :null => false, :default => 0
|
107
|
-
end
|
108
|
-
|
109
|
-
create_table :minimalistics, :force => true do |t|
|
110
|
-
end
|
111
|
-
|
112
|
-
create_table :mixed_case_monkeys, :force => true, :id => false do |t|
|
113
|
-
t.primary_key :monkeyID
|
114
|
-
t.integer :fleaCount
|
115
|
-
end
|
116
|
-
|
117
|
-
create_table :mixins, :force => true do |t|
|
118
|
-
t.integer :parent_id
|
119
|
-
t.integer :pos
|
120
|
-
t.datetime :created_at
|
121
|
-
t.datetime :updated_at
|
122
|
-
t.integer :lft
|
123
|
-
t.integer :rgt
|
124
|
-
t.integer :root_id
|
125
|
-
t.string :type
|
126
|
-
end
|
127
|
-
|
128
|
-
create_table :movies, :force => true, :id => false do |t|
|
129
|
-
t.primary_key :movieid
|
130
|
-
t.string :name
|
131
|
-
end
|
132
|
-
|
133
|
-
create_table :numeric_data, :force => true do |t|
|
134
|
-
t.decimal :bank_balance, :precision => 10, :scale => 2
|
135
|
-
t.decimal :big_bank_balance, :precision => 15, :scale => 2
|
136
|
-
t.decimal :world_population, :precision => 10, :scale => 0
|
137
|
-
t.decimal :my_house_population, :precision => 2, :scale => 0
|
138
|
-
t.decimal :decimal_number_with_default, :precision => 3, :scale => 2, :default => 2.78
|
139
|
-
end
|
140
|
-
|
141
|
-
create_table :orders, :force => true do |t|
|
142
|
-
t.string :name
|
143
|
-
t.integer :billing_customer_id
|
144
|
-
t.integer :shipping_customer_id
|
145
|
-
end
|
146
|
-
|
147
|
-
create_table :people, :force => true do |t|
|
148
|
-
t.string :first_name, :null => false
|
149
|
-
t.integer :lock_version, :null => false, :default => 0
|
150
|
-
end
|
151
|
-
|
152
|
-
create_table :posts, :force => true do |t|
|
153
|
-
t.integer :author_id
|
154
|
-
t.string :title, :null => false
|
155
|
-
t.text :body, :null => false
|
156
|
-
t.string :type
|
157
|
-
end
|
158
|
-
|
159
|
-
create_table :projects, :force => true do |t|
|
160
|
-
t.string :name
|
161
|
-
t.string :type
|
162
|
-
end
|
163
|
-
|
164
|
-
create_table :readers, :force => true do |t|
|
165
|
-
t.integer :post_id, :null => false
|
166
|
-
t.integer :person_id, :null => false
|
167
|
-
end
|
168
|
-
|
169
|
-
create_table :subscribers, :force => true, :id => false do |t|
|
170
|
-
t.string :nick, :null => false
|
171
|
-
t.string :name
|
172
|
-
end
|
173
|
-
add_index :subscribers, :nick, :unique => true
|
174
|
-
|
175
|
-
create_table :tasks, :force => true do |t|
|
176
|
-
t.datetime :starting
|
177
|
-
t.datetime :ending
|
178
|
-
end
|
179
|
-
|
180
|
-
create_table :topics, :force => true do |t|
|
181
|
-
t.string :title
|
182
|
-
t.string :author_name
|
183
|
-
t.string :author_email_address
|
184
|
-
t.datetime :written_on
|
185
|
-
t.time :bonus_time
|
186
|
-
t.date :last_read
|
187
|
-
t.text :content
|
188
|
-
t.boolean :approved, :default => true
|
189
|
-
t.integer :replies_count, :default => 0
|
190
|
-
t.integer :parent_id
|
191
|
-
t.string :type
|
192
|
-
end
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
### These tables are created last as the order is significant
|
197
|
-
|
198
|
-
# fk_test_has_fk should be before fk_test_has_pk
|
199
|
-
create_table :fk_test_has_fk, :force => true do |t|
|
200
|
-
t.integer :fk_id, :null => false
|
201
|
-
end
|
202
|
-
|
203
|
-
create_table :fk_test_has_pk, :force => true do |t|
|
204
|
-
end
|
205
|
-
|
206
|
-
execute 'alter table fk_test_has_fk
|
207
|
-
add FOREIGN KEY (`fk_id`) REFERENCES `fk_test_has_pk`(`id`)'
|
208
|
-
|
209
|
-
|
210
|
-
end
|
211
|
-
|
212
|
-
# For Firebird, set the sequence values 10000 when create_table is called;
|
213
|
-
# this prevents primary key collisions between "normally" created records
|
214
|
-
# and fixture-based (YAML) records.
|
215
|
-
if adapter_name == "Firebird"
|
216
|
-
def create_table(*args, &block)
|
217
|
-
ActiveRecord::Base.connection.create_table(*args, &block)
|
218
|
-
ActiveRecord::Base.connection.execute "SET GENERATOR #{args.first}_seq TO 10000"
|
219
|
-
end
|
220
|
-
end
|
221
|
-
|
222
|
-
create_table :taggings, :force => true do |t|
|
223
|
-
t.column :tag_id, :integer
|
224
|
-
t.column :super_tag_id, :integer
|
225
|
-
t.column :taggable_type, :string
|
226
|
-
t.column :taggable_id, :integer
|
227
|
-
end
|
228
|
-
|
229
|
-
create_table :tags, :force => true do |t|
|
230
|
-
t.column :name, :string
|
231
|
-
t.column :taggings_count, :integer, :default => 0
|
232
|
-
end
|
233
|
-
|
234
|
-
create_table :categorizations, :force => true do |t|
|
235
|
-
t.column :category_id, :integer
|
236
|
-
t.column :post_id, :integer
|
237
|
-
t.column :author_id, :integer
|
238
|
-
end
|
239
|
-
|
240
|
-
add_column :posts, :taggings_count, :integer, :default => 0
|
241
|
-
add_column :authors, :author_address_id, :integer
|
242
|
-
|
243
|
-
create_table :author_addresses, :force => true do |t|
|
244
|
-
t.column :author_address_id, :integer
|
245
|
-
end
|
246
|
-
|
247
|
-
create_table :author_favorites, :force => true do |t|
|
248
|
-
t.column :author_id, :integer
|
249
|
-
t.column :favorite_author_id, :integer
|
250
|
-
end
|
251
|
-
|
252
|
-
create_table :vertices, :force => true do |t|
|
253
|
-
t.column :label, :string
|
254
|
-
end
|
255
|
-
|
256
|
-
create_table :edges, :force => true do |t|
|
257
|
-
t.column :source_id, :integer, :null => false
|
258
|
-
t.column :sink_id, :integer, :null => false
|
259
|
-
end
|
260
|
-
add_index :edges, [:source_id, :sink_id], :unique => true, :name => 'unique_edge_index'
|
261
|
-
|
262
|
-
create_table :lock_without_defaults, :force => true do |t|
|
263
|
-
t.column :lock_version, :integer
|
264
|
-
end
|
265
|
-
|
266
|
-
create_table :lock_without_defaults_cust, :force => true do |t|
|
267
|
-
t.column :custom_lock_version, :integer
|
268
|
-
end
|
269
|
-
|
270
|
-
create_table :items, :force => true do |t|
|
271
|
-
t.column :name, :integer
|
272
|
-
end
|
273
|
-
|
274
|
-
# For sqlite 3.1.0+, make a table with a autoincrement column
|
275
|
-
if adapter_name == 'SQLite' and supports_autoincrement?
|
276
|
-
create_table :table_with_autoincrement, :force => true do |t|
|
277
|
-
t.column :name, :string
|
278
|
-
end
|
279
|
-
end
|
280
|
-
|
281
|
-
# For sqlserver 2000+, ensure real columns can be used
|
282
|
-
if adapter_name.starts_with?("SQLServer")
|
283
|
-
create_table :table_with_real_columns, :force => true do |t|
|
284
|
-
t.column :real_number, :real
|
285
|
-
end
|
286
|
-
end
|
287
|
-
|
288
|
-
create_table :audit_logs, :force => true do |t|
|
289
|
-
t.column :message, :string, :null=>false
|
290
|
-
t.column :developer_id, :integer, :null=>false
|
291
|
-
end
|
292
|
-
|
293
|
-
create_table :books, :force => true do |t|
|
294
|
-
t.column :name, :string
|
295
|
-
end
|
296
|
-
|
297
|
-
create_table :citations, :force => true do |t|
|
298
|
-
t.column :book1_id, :integer
|
299
|
-
t.column :book2_id, :integer
|
300
|
-
end
|
301
|
-
|
302
|
-
create_table :inept_wizards, :force => true do |t|
|
303
|
-
t.column :name, :string, :null => false
|
304
|
-
t.column :city, :string, :null => false
|
305
|
-
t.column :type, :string
|
306
|
-
end
|
307
|
-
|
308
|
-
create_table :parrots, :force => true do |t|
|
309
|
-
t.column :name, :string
|
310
|
-
t.column :parrot_sti_class, :string
|
311
|
-
t.column :killer_id, :integer
|
312
|
-
t.column :created_at, :datetime
|
313
|
-
t.column :created_on, :datetime
|
314
|
-
t.column :updated_at, :datetime
|
315
|
-
t.column :updated_on, :datetime
|
316
|
-
end
|
317
|
-
|
318
|
-
create_table :pirates, :force => true do |t|
|
319
|
-
t.column :catchphrase, :string
|
320
|
-
t.column :parrot_id, :integer
|
321
|
-
t.column :created_on, :datetime
|
322
|
-
t.column :updated_on, :datetime
|
323
|
-
end
|
324
|
-
|
325
|
-
create_table :parrots_pirates, :id => false, :force => true do |t|
|
326
|
-
t.column :parrot_id, :integer
|
327
|
-
t.column :pirate_id, :integer
|
328
|
-
end
|
329
|
-
|
330
|
-
create_table :treasures, :force => true do |t|
|
331
|
-
t.column :name, :string
|
332
|
-
t.column :looter_id, :integer
|
333
|
-
t.column :looter_type, :string
|
334
|
-
end
|
335
|
-
|
336
|
-
create_table :parrots_treasures, :id => false, :force => true do |t|
|
337
|
-
t.column :parrot_id, :integer
|
338
|
-
t.column :treasure_id, :integer
|
339
|
-
end
|
340
|
-
|
341
|
-
create_table :mateys, :id => false, :force => true do |t|
|
342
|
-
t.column :pirate_id, :integer
|
343
|
-
t.column :target_id, :integer
|
344
|
-
t.column :weight, :integer
|
345
|
-
end
|
346
|
-
|
347
|
-
create_table :ships, :force => true do |t|
|
348
|
-
t.string :name
|
349
|
-
t.datetime :created_at
|
350
|
-
t.datetime :created_on
|
351
|
-
t.datetime :updated_at
|
352
|
-
t.datetime :updated_on
|
353
|
-
end
|
354
|
-
end
|