model_from_table 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 29ea26621c13e3d7eacfdc05d7f581419c90bf07
4
- data.tar.gz: 123ed2960f5486e7b4f29714693605970910f5fa
3
+ metadata.gz: 1ce74c140eaafcca398003a6517f346bb994e399
4
+ data.tar.gz: befd16f6cde3e2b5e139b145c9ebcc4135087887
5
5
  SHA512:
6
- metadata.gz: 65807431e2dd323ca7e2ed0eb1195f6465b4d14d23c24938186e529c93cfffbb7892fed26faa371636ef762d66f330027c28e66ebcf6e35fa429944b1869cef8
7
- data.tar.gz: e5569da2b078e137201825c0c84cf1b6cf7fc0751b3028e8c5d6ae010caac9c96c152644790160db1af1e7abe070379f3d3c22d8e84733b1db29a4637877454b
6
+ metadata.gz: 3005c672a6f3defa2a759e96253a6206f5c966b75f60be04697e1d8cf565c9bfa0e6f4a4d6ec0cd06a9ad6a7487c39dde013f1a160607891bff9d79d873add8c
7
+ data.tar.gz: 700b46b5634cc71d7eb0b0dbc4e527528e3cb0c1e2a3755ce32dafc455b168b62be327f32e1e5e6c0a8a2166876ff712786ed168a0a64c6efeeabf4a6dc71ab2
@@ -50,5 +50,13 @@ class ModelFromTableGenerator < Rails::Generators::Base
50
50
 
51
51
  @pk
52
52
  end
53
+
54
+ def belongs_to_syms
55
+ belongs_to_columns.map { |col| col.name.sub('_id', '').to_sym }
56
+ end
57
+
58
+ def belongs_to_columns
59
+ @connection.columns(table_name).select { |col| col.name =~ /^.*_id$/ }
60
+ end
53
61
  end
54
62
  end
@@ -5,4 +5,7 @@ class <%= @resource.class_name %> < ActiveRecord::Base
5
5
  <%- if @resource.primary_key_required? -%>
6
6
  self.primary_key = "<%= @resource.primary_key %>"
7
7
  <%- end -%>
8
+ <%- @resource.belongs_to_syms.each do |sym| -%>
9
+ belongs_to :<%= sym %>
10
+ <%- end -%>
8
11
  end
@@ -1,3 +1,3 @@
1
1
  module ModelFromTable
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
Binary file
@@ -12,5 +12,10 @@ class CreateTables < ActiveRecord::Migration
12
12
  t.primary_key:code
13
13
  t.string :name
14
14
  end
15
+
16
+ create_table :song, id: false do |t|
17
+ t.primary_key :song_code
18
+ t.integer :user_id
19
+ end
15
20
  end
16
21
  end
@@ -21,6 +21,10 @@ ActiveRecord::Schema.define(version: 20140728150510) do
21
21
  t.string "name"
22
22
  end
23
23
 
24
+ create_table "song", primary_key: "song_code", force: true do |t|
25
+ t.integer "user_id"
26
+ end
27
+
24
28
  create_table "users", force: true do |t|
25
29
  t.string "name"
26
30
  end
Binary file
File without changes
@@ -1,97 +1,68 @@
1
-
2
-
3
- Started GET "/themes" for 127.0.0.1 at 2014-07-26 00:13:34 +0900
4
-
5
- ActionController::RoutingError (No route matches [GET] "/themes"):
6
- actionpack (4.1.4) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
7
- actionpack (4.1.4) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
8
- railties (4.1.4) lib/rails/rack/logger.rb:38:in `call_app'
9
- railties (4.1.4) lib/rails/rack/logger.rb:20:in `block in call'
10
- activesupport (4.1.4) lib/active_support/tagged_logging.rb:68:in `block in tagged'
11
- activesupport (4.1.4) lib/active_support/tagged_logging.rb:26:in `tagged'
12
- activesupport (4.1.4) lib/active_support/tagged_logging.rb:68:in `tagged'
13
- railties (4.1.4) lib/rails/rack/logger.rb:20:in `call'
14
- actionpack (4.1.4) lib/action_dispatch/middleware/request_id.rb:21:in `call'
15
- rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
16
- rack (1.5.2) lib/rack/runtime.rb:17:in `call'
17
- activesupport (4.1.4) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
18
- rack (1.5.2) lib/rack/lock.rb:17:in `call'
19
- actionpack (4.1.4) lib/action_dispatch/middleware/static.rb:64:in `call'
20
- rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
21
- railties (4.1.4) lib/rails/engine.rb:514:in `call'
22
- railties (4.1.4) lib/rails/application.rb:144:in `call'
23
- rack (1.5.2) lib/rack/lock.rb:17:in `call'
24
- rack (1.5.2) lib/rack/content_length.rb:14:in `call'
25
- rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service'
26
- /Users/hidenorimaehara/.rbenv/versions/2.1.1/lib/ruby/2.1.0/webrick/httpserver.rb:138:in `service'
27
- /Users/hidenorimaehara/.rbenv/versions/2.1.1/lib/ruby/2.1.0/webrick/httpserver.rb:94:in `run'
28
- /Users/hidenorimaehara/.rbenv/versions/2.1.1/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread'
29
-
30
-
31
- Rendered /Users/hidenorimaehara/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/actionpack-4.1.4/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (2.4ms)
32
- Rendered /Users/hidenorimaehara/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/actionpack-4.1.4/lib/action_dispatch/middleware/templates/routes/_table.html.erb (37.2ms)
33
- Rendered /Users/hidenorimaehara/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/actionpack-4.1.4/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb within rescues/layout (79.4ms)
34
-
35
-
36
- Started GET "/m3_admin" for 127.0.0.1 at 2014-07-26 00:13:34 +0900
37
-
38
- ActionController::RoutingError (No route matches [GET] "/m3_admin"):
39
- actionpack (4.1.4) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
40
- actionpack (4.1.4) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
41
- railties (4.1.4) lib/rails/rack/logger.rb:38:in `call_app'
42
- railties (4.1.4) lib/rails/rack/logger.rb:20:in `block in call'
43
- activesupport (4.1.4) lib/active_support/tagged_logging.rb:68:in `block in tagged'
44
- activesupport (4.1.4) lib/active_support/tagged_logging.rb:26:in `tagged'
45
- activesupport (4.1.4) lib/active_support/tagged_logging.rb:68:in `tagged'
46
- railties (4.1.4) lib/rails/rack/logger.rb:20:in `call'
47
- actionpack (4.1.4) lib/action_dispatch/middleware/request_id.rb:21:in `call'
48
- rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
49
- rack (1.5.2) lib/rack/runtime.rb:17:in `call'
50
- activesupport (4.1.4) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
51
- rack (1.5.2) lib/rack/lock.rb:17:in `call'
52
- actionpack (4.1.4) lib/action_dispatch/middleware/static.rb:64:in `call'
53
- rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
54
- railties (4.1.4) lib/rails/engine.rb:514:in `call'
55
- railties (4.1.4) lib/rails/application.rb:144:in `call'
56
- rack (1.5.2) lib/rack/lock.rb:17:in `call'
57
- rack (1.5.2) lib/rack/content_length.rb:14:in `call'
58
- rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service'
59
- /Users/hidenorimaehara/.rbenv/versions/2.1.1/lib/ruby/2.1.0/webrick/httpserver.rb:138:in `service'
60
- /Users/hidenorimaehara/.rbenv/versions/2.1.1/lib/ruby/2.1.0/webrick/httpserver.rb:94:in `run'
61
- /Users/hidenorimaehara/.rbenv/versions/2.1.1/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread'
62
-
63
-
64
- Rendered /Users/hidenorimaehara/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/actionpack-4.1.4/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (2.4ms)
65
- Rendered /Users/hidenorimaehara/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/actionpack-4.1.4/lib/action_dispatch/middleware/templates/routes/_table.html.erb (2.3ms)
66
- Rendered /Users/hidenorimaehara/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/actionpack-4.1.4/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb within rescues/layout (19.8ms)
67
-
68
-
69
- Started GET "/" for 127.0.0.1 at 2014-07-26 00:13:37 +0900
70
- Processing by Rails::WelcomeController#index as HTML
71
- Rendered /Users/hidenorimaehara/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/railties-4.1.4/lib/rails/templates/rails/welcome/index.html.erb (1.1ms)
72
- Completed 200 OK in 18ms (Views: 18.2ms | ActiveRecord: 0.0ms)
73
- ActiveRecord::SchemaMigration Load (1.0ms) SELECT "schema_migrations".* FROM "schema_migrations"
74
-  (1.3ms) BEGIN
75
- SQL (2.5ms) INSERT INTO "some_legacy_table" ("name") VALUES ($1) RETURNING "code" [["name", "hoge"]]
76
-  (3.2ms) COMMIT
77
- TmeCareerInterest Load (4.2ms) SELECT "tme_career_interests".* FROM "tme_career_interests" ORDER BY "tme_career_interests"."id" ASC LIMIT 1
78
- TmeProfile Load (3.5ms) SELECT "tme_profiles".* FROM "tme_profiles" ORDER BY "tme_profiles"."id" ASC LIMIT 1
79
-  (0.3ms) BEGIN
80
- SQL (8.5ms) INSERT INTO "tme_profiles" ("created_at", "system_cd", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["created_at", "2014-07-26 12:01:17.351176"], ["system_cd", "aaa"], ["updated_at", "2014-07-26 12:01:17.351176"]]
81
-  (3.8ms) COMMIT
82
-  (0.3ms) BEGIN
83
- SQL (4.3ms) INSERT INTO "some_legacy_table" DEFAULT VALUES RETURNING "code"
84
- PG::NotNullViolation: ERROR: null value in column "name" violates not-null constraint
85
- DETAIL: Failing row contains (2, null).
86
- : INSERT INTO "some_legacy_table" DEFAULT VALUES RETURNING "code"
87
-  (0.3ms) ROLLBACK
88
-  (0.3ms) BEGIN
89
-  (0.3ms) ROLLBACK
90
- SomeLegacyTable Load (0.7ms) SELECT "code".* FROM "code" ORDER BY "code"."id" ASC LIMIT 1
91
- PG::UndefinedTable: ERROR: relation "code" does not exist
92
- LINE 1: SELECT "code".* FROM "code" ORDER BY "code"."id" ASC LIMI...
93
- ^
94
- : SELECT "code".* FROM "code" ORDER BY "code"."id" ASC LIMIT 1
95
- SomeLegacyTable Load (4.9ms) SELECT "some_legacy_table".* FROM "some_legacy_table" ORDER BY "some_legacy_table"."code" ASC LIMIT 1
96
- Consultant Load (0.3ms) SELECT "consultant".* FROM "consultant" ORDER BY "consultant"."id" ASC LIMIT 1
97
- SQLite3::SQLException: no such table: consultant: SELECT "consultant".* FROM "consultant" ORDER BY "consultant"."id" ASC LIMIT 1
1
+  (1.2ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
2
+  (0.5ms) select sqlite_version(*)
3
+  (1.3ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
4
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
5
+ Migrating to CreateTables (20140728150510)
6
+  (0.1ms) begin transaction
7
+  (0.5ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
8
+  (0.2ms) CREATE TABLE "company" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
9
+  (0.1ms) CREATE TABLE "legacy_table" ("code" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
10
+ SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140728150510"]]
11
+  (1.2ms) commit transaction
12
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
13
+  (1.3ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
14
+  (0.1ms) select sqlite_version(*)
15
+  (1.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
16
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
17
+ Migrating to CreateTables (20140728150510)
18
+  (0.1ms) begin transaction
19
+  (0.4ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
20
+  (0.2ms) CREATE TABLE "company" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
21
+  (0.1ms) CREATE TABLE "legacy_table" ("code" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
22
+  (0.1ms) CREATE TABLE "song" ("song_code" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "user_id" integer) 
23
+ SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140728150510"]]
24
+  (1.5ms) commit transaction
25
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
26
+ Song Load (3.2ms) SELECT "song".* FROM "song" ORDER BY "song"."song_code" ASC LIMIT 1
27
+ Song Load (2.6ms) SELECT "song".* FROM "song" ORDER BY "song"."song_code" ASC LIMIT 1
28
+  (1.1ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
29
+  (0.1ms) select sqlite_version(*)
30
+  (0.9ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
31
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
32
+ Migrating to CreateTables (20140728150510)
33
+  (0.1ms) begin transaction
34
+  (0.7ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
35
+  (0.2ms) CREATE TABLE "company" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
36
+  (0.3ms) CREATE TABLE "legacy_table" ("code" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
37
+  (0.2ms) CREATE TABLE "song" ("song_code" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "user_id" integer, "type" varchar(255)) 
38
+ SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140728150510"]]
39
+  (1.0ms) commit transaction
40
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
41
+ Song Load (2.2ms) SELECT "song".* FROM "song" ORDER BY "song"."song_code" ASC LIMIT 1
42
+  (0.1ms) begin transaction
43
+ SQL (0.4ms) INSERT INTO "song" ("type") VALUES (?) [["type", "hoge"]]
44
+  (1.2ms) commit transaction
45
+ Song Load (0.3ms) SELECT "song".* FROM "song" ORDER BY "song"."song_code" ASC LIMIT 1
46
+  (1.3ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
47
+  (0.4ms) select sqlite_version(*)
48
+  (1.0ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
49
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
50
+ Migrating to CreateTables (20140728150510)
51
+  (0.1ms) begin transaction
52
+  (0.4ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
53
+  (0.1ms) CREATE TABLE "company" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
54
+  (0.2ms) CREATE TABLE "legacy_table" ("code" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
55
+  (0.3ms) CREATE TABLE "song" ("song_code" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "user_id" integer) 
56
+ SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140728150510"]]
57
+  (1.3ms) commit transaction
58
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
59
+  (0.1ms) begin transaction
60
+ SQL (0.4ms) INSERT INTO "song" ("user_id") VALUES (?) [["user_id", 1]]
61
+  (1.2ms) commit transaction
62
+  (0.1ms) begin transaction
63
+ SQL (0.5ms) INSERT INTO "users" ("name") VALUES (?) [["name", "hoge"]]
64
+  (3.2ms) commit transaction
65
+ Song Load (0.2ms) SELECT "song".* FROM "song" ORDER BY "song"."song_code" ASC LIMIT 1
66
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 1]]
67
+ User Load (0.2ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1
68
+ User Load (0.2ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1
@@ -1,478 +1,196 @@
1
1
   (0.1ms) begin transaction
2
- ------------------------------
3
- ModelFromTableTest: test_truth
4
- ------------------------------
5
-  (0.1ms) rollback transaction
6
-  (0.1ms) begin transaction
7
- ------------------------------
8
- ModelFromTableTest: test_truth
9
- ------------------------------
10
-  (0.1ms) rollback transaction
11
-  (0.1ms) begin transaction
12
- ------------------------------
13
- ModelFromTableTest: test_truth
14
- ------------------------------
15
-  (0.1ms) rollback transaction
16
-  (0.1ms) begin transaction
17
- ----------------------------------
18
- ModelFromTableTest: test_resources
19
- ----------------------------------
20
-  (0.1ms) rollback transaction
21
-  (0.1ms) begin transaction
22
- ------------------------------
23
- ModelFromTableTest: test_truth
24
- ------------------------------
25
-  (0.0ms) rollback transaction
26
-  (0.1ms) begin transaction
27
- ----------------------------------
28
- ModelFromTableTest: test_resources
29
- ----------------------------------
30
-  (0.1ms) rollback transaction
31
-  (0.1ms) begin transaction
32
- ------------------------------
33
- ModelFromTableTest: test_truth
34
- ------------------------------
35
-  (0.0ms) rollback transaction
36
-  (0.1ms) begin transaction
37
- ----------------------------------
38
- ModelFromTableTest: test_resources
39
- ----------------------------------
40
-  (0.1ms) rollback transaction
41
-  (0.0ms) begin transaction
42
- ------------------------------
43
- ModelFromTableTest: test_truth
44
- ------------------------------
45
-  (0.0ms) rollback transaction
46
-  (0.1ms) begin transaction
47
- ----------------------------------
48
- ModelFromTableTest: test_resources
49
- ----------------------------------
50
-  (0.1ms) rollback transaction
51
-  (0.1ms) begin transaction
52
- ------------------------------
53
- ModelFromTableTest: test_truth
54
- ------------------------------
55
-  (0.0ms) rollback transaction
56
-  (0.1ms) begin transaction
57
- ----------------------------------
58
- ModelFromTableTest: test_resources
59
- ----------------------------------
60
-  (0.4ms) rollback transaction
61
-  (0.1ms) begin transaction
62
- ------------------------------
63
- ModelFromTableTest: test_truth
64
- ------------------------------
65
-  (0.1ms) rollback transaction
66
-  (0.1ms) begin transaction
67
- ----------------------------------
68
- ModelFromTableTest: test_resources
69
- ----------------------------------
70
-  (0.1ms) rollback transaction
71
-  (0.1ms) begin transaction
72
- ------------------------------
73
- ModelFromTableTest: test_truth
74
- ------------------------------
75
-  (0.0ms) rollback transaction
76
-  (0.1ms) begin transaction
77
- ----------------------------------
78
- ModelFromTableTest: test_resources
79
- ----------------------------------
80
-  (0.1ms) rollback transaction
81
-  (0.0ms) begin transaction
82
- ------------------------------
83
- ModelFromTableTest: test_truth
84
- ------------------------------
85
-  (0.0ms) rollback transaction
86
-  (0.1ms) begin transaction
87
- ----------------------------------
88
- ModelFromTableTest: test_resources
89
- ----------------------------------
90
-  (0.1ms) rollback transaction
91
-  (0.0ms) begin transaction
92
- ------------------------------
93
- ModelFromTableTest: test_truth
94
- ------------------------------
95
-  (0.0ms) rollback transaction
96
-  (0.1ms) begin transaction
97
- ----------------------------------
98
- ModelFromTableTest: test_resources
99
- ----------------------------------
100
-  (7.0ms) rollback transaction
101
-  (0.1ms) begin transaction
102
- ------------------------------
103
- ModelFromTableTest: test_truth
104
- ------------------------------
105
-  (0.1ms) rollback transaction
106
-  (0.1ms) begin transaction
107
- ----------------------------------
108
- ModelFromTableTest: test_resources
109
- ----------------------------------
110
-  (0.1ms) rollback transaction
111
-  (0.1ms) begin transaction
112
- ------------------------------
113
- ModelFromTableTest: test_truth
114
- ------------------------------
115
-  (0.0ms) rollback transaction
116
-  (0.2ms) begin transaction
117
- ----------------------------------
118
- ModelFromTableTest: test_resources
119
- ----------------------------------
120
-  (0.1ms) rollback transaction
121
-  (0.1ms) begin transaction
122
- ------------------------------
123
- ModelFromTableTest: test_truth
124
- ------------------------------
125
-  (0.1ms) rollback transaction
126
-  (0.1ms) begin transaction
127
- ----------------------------------
128
- ModelFromTableTest: test_resources
129
- ----------------------------------
130
-  (0.1ms) rollback transaction
131
-  (0.1ms) begin transaction
132
- ------------------------------
133
- ModelFromTableTest: test_truth
134
- ------------------------------
135
-  (0.0ms) rollback transaction
136
-  (0.1ms) begin transaction
137
- ----------------------------------
138
- ModelFromTableTest: test_resources
139
- ----------------------------------
140
-  (0.1ms) rollback transaction
141
-  (0.0ms) begin transaction
142
- ------------------------------
143
- ModelFromTableTest: test_truth
144
- ------------------------------
145
-  (0.0ms) rollback transaction
146
-  (0.1ms) begin transaction
147
- ----------------------------------
148
- ModelFromTableTest: test_resources
149
- ----------------------------------
150
-  (0.1ms) rollback transaction
151
-  (0.0ms) begin transaction
152
- ------------------------------
153
- ModelFromTableTest: test_truth
154
- ------------------------------
155
-  (0.0ms) rollback transaction
156
-  (0.1ms) begin transaction
157
- ----------------------------------
158
- ModelFromTableTest: test_resources
159
- ----------------------------------
160
-  (0.1ms) rollback transaction
161
-  (0.0ms) begin transaction
162
- ------------------------------
163
- ModelFromTableTest: test_truth
164
- ------------------------------
165
-  (0.0ms) rollback transaction
166
-  (0.1ms) begin transaction
167
- ----------------------------------
168
- ModelFromTableTest: test_resources
169
- ----------------------------------
2
+ -------------------------------------------------------
3
+ ModelFromTableGeneratorTest: test_all_files_are_created
4
+ -------------------------------------------------------
170
5
   (0.1ms) rollback transaction
171
6
   (0.0ms) begin transaction
172
- ------------------------------
173
- ModelFromTableTest: test_truth
174
- ------------------------------
175
-  (0.1ms) rollback transaction
176
-  (0.1ms) begin transaction
177
- ----------------------------------
178
- ModelFromTableTest: test_resources
179
- ----------------------------------
180
-  (0.1ms) rollback transaction
181
-  (0.1ms) begin transaction
182
- ------------------------------
183
- ModelFromTableTest: test_truth
184
- ------------------------------
185
-  (0.1ms) rollback transaction
186
-  (0.1ms) begin transaction
187
- ----------------------------------
188
- ModelFromTableTest: test_resources
189
- ----------------------------------
190
-  (0.1ms) rollback transaction
191
-  (0.1ms) begin transaction
192
- ----------------------------------
193
- ModelFromTableTest: test_resources
194
- ----------------------------------
195
-  (0.1ms) rollback transaction
196
-  (0.1ms) begin transaction
197
- ----------------------------------
198
- ModelFromTableTest: test_resources
199
- ----------------------------------
200
-  (0.1ms) rollback transaction
201
-  (0.1ms) begin transaction
202
- ----------------------------------
203
- ModelFromTableTest: test_resources
204
- ----------------------------------
205
-  (0.1ms) rollback transaction
206
-  (0.1ms) begin transaction
207
- ----------------------------------
208
- ModelFromTableTest: test_resources
209
- ----------------------------------
210
-  (6.0ms) rollback transaction
211
-  (0.1ms) begin transaction
212
- ----------------------------------
213
- ModelFromTableTest: test_resources
214
- ----------------------------------
215
-  (0.1ms) rollback transaction
216
-  (0.1ms) begin transaction
217
- ----------------------------------
218
- ModelFromTableTest: test_resources
219
- ----------------------------------
220
-  (0.1ms) rollback transaction
221
-  (0.1ms) begin transaction
222
- -------------------------------------------
223
- ModelFromTableGeneratorTest: test_resources
224
- -------------------------------------------
225
-  (0.1ms) rollback transaction
226
-  (0.1ms) begin transaction
227
- -------------------------------------------
228
- ModelFromTableGeneratorTest: test_resources
229
- -------------------------------------------
230
-  (0.1ms) rollback transaction
231
-  (0.1ms) begin transaction
232
- -------------------------------------------
233
- ModelFromTableGeneratorTest: test_resources
234
- -------------------------------------------
235
-  (0.1ms) rollback transaction
236
-  (0.1ms) begin transaction
237
- -------------------------------------------
238
- ModelFromTableGeneratorTest: test_resources
239
- -------------------------------------------
240
-  (0.1ms) rollback transaction
241
-  (0.1ms) begin transaction
242
- -------------------------------------------
243
- ModelFromTableGeneratorTest: test_resources
244
- -------------------------------------------
245
-  (0.1ms) rollback transaction
246
-  (0.1ms) begin transaction
247
- -------------------------------------------
248
- ModelFromTableGeneratorTest: test_resources
249
- -------------------------------------------
250
-  (0.1ms) rollback transaction
251
-  (0.1ms) begin transaction
252
- -------------------------------------------
253
- ModelFromTableGeneratorTest: test_resources
254
- -------------------------------------------
255
-  (0.1ms) rollback transaction
256
-  (0.1ms) begin transaction
257
- -------------------------------------------
258
- ModelFromTableGeneratorTest: test_resources
259
- -------------------------------------------
260
-  (0.1ms) rollback transaction
261
-  (0.1ms) begin transaction
262
- -------------------------------------------
263
- ModelFromTableGeneratorTest: test_resources
264
- -------------------------------------------
265
-  (0.1ms) rollback transaction
266
-  (0.1ms) begin transaction
267
- -------------------------------------------
268
- ModelFromTableGeneratorTest: test_resources
269
- -------------------------------------------
270
-  (0.1ms) rollback transaction
271
-  (0.1ms) begin transaction
272
- -------------------------------------------
273
- ModelFromTableGeneratorTest: test_resources
274
- -------------------------------------------
275
-  (0.1ms) rollback transaction
276
-  (0.1ms) begin transaction
277
- -------------------------------------------
278
- ModelFromTableGeneratorTest: test_resources
279
- -------------------------------------------
280
-  (0.1ms) rollback transaction
281
-  (0.1ms) begin transaction
282
- -------------------------------------------
283
- ModelFromTableGeneratorTest: test_resources
284
- -------------------------------------------
285
-  (0.1ms) rollback transaction
286
-  (0.1ms) begin transaction
287
- -------------------------------------------
288
- ModelFromTableGeneratorTest: test_resources
289
- -------------------------------------------
290
-  (0.1ms) rollback transaction
291
-  (0.1ms) begin transaction
292
- -------------------------------------------
293
- ModelFromTableGeneratorTest: test_resources
294
- -------------------------------------------
7
+ ----------------------------------------------------------------
8
+ ModelFromTableGeneratorTest: test_not_create_schema_migration.rb
9
+ ----------------------------------------------------------------
295
10
   (0.1ms) rollback transaction
296
11
   (0.1ms) begin transaction
297
- -------------------------------------------
298
- ModelFromTableGeneratorTest: test_resources
299
- -------------------------------------------
12
+ --------------------------------------------------
13
+ ModelFromTableGeneratorTest: test_rails_convension
14
+ --------------------------------------------------
300
15
   (0.1ms) rollback transaction
301
16
   (0.1ms) begin transaction
302
- -------------------------------------------
303
- ModelFromTableGeneratorTest: test_resources
304
- -------------------------------------------
17
+ ------------------------------------------------------------------------------------
18
+ ModelFromTableGeneratorTest: test_table_name_and_primary_key_is_not_rails_convension
19
+ ------------------------------------------------------------------------------------
305
20
   (0.1ms) rollback transaction
306
21
   (0.1ms) begin transaction
307
- -------------------------------------------
308
- ModelFromTableGeneratorTest: test_resources
309
- -------------------------------------------
22
+ --------------------------------------------------------------------
23
+ ModelFromTableGeneratorTest: test_table_name_is_not_rails_convension
24
+ --------------------------------------------------------------------
310
25
   (0.1ms) rollback transaction
26
+  (1.1ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
27
+  (0.1ms) select sqlite_version(*)
28
+  (1.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
29
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
30
+ Migrating to CreateTables (20140728150510)
311
31
   (0.1ms) begin transaction
312
- -------------------------------------------
313
- ModelFromTableGeneratorTest: test_resources
314
- -------------------------------------------
315
-  (0.1ms) rollback transaction
316
- ActiveRecord::SchemaMigration Load (17.6ms) SELECT "schema_migrations".* FROM "schema_migrations"
317
-  (1.3ms) BEGIN
318
- -------------------------------------------
319
- ModelFromTableGeneratorTest: test_resources
320
- -------------------------------------------
321
-  (0.3ms) ROLLBACK
322
- ActiveRecord::SchemaMigration Load (1.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
323
-  (0.3ms) BEGIN
324
- -------------------------------------------
325
- ModelFromTableGeneratorTest: test_resources
326
- -------------------------------------------
327
-  (0.4ms) ROLLBACK
328
- ActiveRecord::SchemaMigration Load (13.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
329
-  (0.8ms) BEGIN
330
- -------------------------------------------
331
- ModelFromTableGeneratorTest: test_resources
332
- -------------------------------------------
333
-  (0.4ms) ROLLBACK
334
- ActiveRecord::SchemaMigration Load (1.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
335
-  (0.3ms) BEGIN
336
- -------------------------------------------------------
337
- ModelFromTableGeneratorTest: test_all_files_are_created
338
- -------------------------------------------------------
339
-  (0.3ms) ROLLBACK
340
- ActiveRecord::SchemaMigration Load (1.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
341
-  (0.3ms) BEGIN
342
- -------------------------------------------------------
343
- ModelFromTableGeneratorTest: test_all_files_are_created
344
- -------------------------------------------------------
345
-  (0.3ms) ROLLBACK
346
- ActiveRecord::SchemaMigration Load (1.0ms) SELECT "schema_migrations".* FROM "schema_migrations"
347
-  (0.3ms) BEGIN
348
- -------------------------------------------------------
349
- ModelFromTableGeneratorTest: test_all_files_are_created
350
- -------------------------------------------------------
351
-  (0.2ms) ROLLBACK
352
- ActiveRecord::SchemaMigration Load (1.0ms) SELECT "schema_migrations".* FROM "schema_migrations"
353
-  (0.4ms) BEGIN
354
- -------------------------------------------------------
355
- ModelFromTableGeneratorTest: test_all_files_are_created
356
- -------------------------------------------------------
357
-  (0.2ms) ROLLBACK
358
- ActiveRecord::SchemaMigration Load (1.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
359
-  (0.3ms) BEGIN
360
- -------------------------------------------------------
361
- ModelFromTableGeneratorTest: test_all_files_are_created
362
- -------------------------------------------------------
363
-  (0.5ms) ROLLBACK
364
- ActiveRecord::SchemaMigration Load (1.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
365
-  (0.3ms) BEGIN
366
- -------------------------------------------------------
367
- ModelFromTableGeneratorTest: test_all_files_are_created
368
- -------------------------------------------------------
369
-  (0.2ms) ROLLBACK
370
- ActiveRecord::SchemaMigration Load (4.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
371
-  (0.5ms) BEGIN
372
- -------------------------------------------------------
373
- ModelFromTableGeneratorTest: test_all_files_are_created
374
- -------------------------------------------------------
375
-  (0.5ms) ROLLBACK
376
- ActiveRecord::SchemaMigration Load (2.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
377
-  (0.6ms) BEGIN
32
+  (0.5ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
33
+  (0.2ms) CREATE TABLE "company" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
34
+  (0.1ms) CREATE TABLE "legacy_table" ("code" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
35
+ SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140728150510"]]
36
+  (1.3ms) commit transaction
37
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
38
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
39
+  (0.1ms) begin transaction
378
40
  -------------------------------------------------------
379
41
  ModelFromTableGeneratorTest: test_all_files_are_created
380
42
  -------------------------------------------------------
381
-  (0.5ms) ROLLBACK
382
-  (0.4ms) BEGIN
43
+  (0.1ms) rollback transaction
44
+  (0.1ms) begin transaction
45
+ ----------------------------------------------------------------
46
+ ModelFromTableGeneratorTest: test_not_create_schema_migration.rb
47
+ ----------------------------------------------------------------
48
+  (0.1ms) rollback transaction
49
+  (0.1ms) begin transaction
50
+ --------------------------------------------------
51
+ ModelFromTableGeneratorTest: test_rails_convension
52
+ --------------------------------------------------
53
+  (0.1ms) rollback transaction
54
+  (0.1ms) begin transaction
383
55
  ------------------------------------------------------------------------------------
384
56
  ModelFromTableGeneratorTest: test_table_name_and_primary_key_is_not_rails_convension
385
57
  ------------------------------------------------------------------------------------
386
-  (0.5ms) ROLLBACK
387
-  (0.4ms) BEGIN
58
+  (0.1ms) rollback transaction
59
+  (0.0ms) begin transaction
388
60
  --------------------------------------------------------------------
389
61
  ModelFromTableGeneratorTest: test_table_name_is_not_rails_convension
390
62
  --------------------------------------------------------------------
391
-  (0.5ms) ROLLBACK
392
- ActiveRecord::SchemaMigration Load (1.9ms) SELECT "schema_migrations".* FROM "schema_migrations"
393
-  (0.5ms) BEGIN
63
+  (0.1ms) rollback transaction
64
+  (1.1ms) CREATE TABLE "company" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
65
+  (1.0ms) CREATE TABLE "legacy_table" ("code" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
66
+  (0.8ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
67
+  (1.2ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
68
+  (0.1ms) select sqlite_version(*)
69
+  (1.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
70
+  (0.2ms) SELECT version FROM "schema_migrations"
71
+  (1.1ms) INSERT INTO "schema_migrations" (version) VALUES ('20140728150510')
72
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
73
+  (1.1ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
74
+  (0.1ms) select sqlite_version(*)
75
+  (0.9ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
76
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
77
+ Migrating to CreateTables (20140728150510)
78
+  (0.1ms) begin transaction
79
+  (0.6ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
80
+  (0.3ms) CREATE TABLE "company" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
81
+  (0.2ms) CREATE TABLE "legacy_table" ("code" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
82
+  (0.3ms) CREATE TABLE "song" ("song_code" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "user_id" integer) 
83
+ SQL (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140728150510"]]
84
+  (1.1ms) commit transaction
85
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
86
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
87
+  (0.1ms) begin transaction
394
88
  -------------------------------------------------------
395
89
  ModelFromTableGeneratorTest: test_all_files_are_created
396
90
  -------------------------------------------------------
397
-  (0.4ms) ROLLBACK
398
-  (0.3ms) BEGIN
91
+  (0.1ms) rollback transaction
92
+  (0.1ms) begin transaction
399
93
  ----------------------------------------------------------------
400
94
  ModelFromTableGeneratorTest: test_not_create_schema_migration.rb
401
95
  ----------------------------------------------------------------
402
-  (0.3ms) ROLLBACK
403
-  (0.2ms) BEGIN
96
+  (0.1ms) rollback transaction
97
+  (0.0ms) begin transaction
98
+ --------------------------------------------------
99
+ ModelFromTableGeneratorTest: test_rails_convension
100
+ --------------------------------------------------
101
+  (0.1ms) rollback transaction
102
+  (0.0ms) begin transaction
404
103
  ------------------------------------------------------------------------------------
405
104
  ModelFromTableGeneratorTest: test_table_name_and_primary_key_is_not_rails_convension
406
105
  ------------------------------------------------------------------------------------
407
-  (0.4ms) ROLLBACK
408
-  (0.3ms) BEGIN
106
+  (0.1ms) rollback transaction
107
+  (0.1ms) begin transaction
409
108
  --------------------------------------------------------------------
410
109
  ModelFromTableGeneratorTest: test_table_name_is_not_rails_convension
411
110
  --------------------------------------------------------------------
412
-  (0.6ms) ROLLBACK
413
- ActiveRecord::SchemaMigration Load (1.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
414
-  (0.4ms) BEGIN
111
+  (0.1ms) rollback transaction
112
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
113
+  (0.1ms) begin transaction
415
114
  -------------------------------------------------------
416
115
  ModelFromTableGeneratorTest: test_all_files_are_created
417
116
  -------------------------------------------------------
418
-  (0.4ms) ROLLBACK
419
-  (0.2ms) BEGIN
117
+  (0.1ms) rollback transaction
118
+  (0.1ms) begin transaction
420
119
  ----------------------------------------------------------------
421
120
  ModelFromTableGeneratorTest: test_not_create_schema_migration.rb
422
121
  ----------------------------------------------------------------
423
-  (0.3ms) ROLLBACK
424
-  (0.3ms) BEGIN
122
+  (0.1ms) rollback transaction
123
+  (0.1ms) begin transaction
124
+ --------------------------------------------------
125
+ ModelFromTableGeneratorTest: test_rails_convension
126
+ --------------------------------------------------
127
+  (0.1ms) rollback transaction
128
+  (0.1ms) begin transaction
129
+ ---------------------------------------------------------------------------
130
+ ModelFromTableGeneratorTest: test_set_belongs_to_if_table_has_xxx_id_column
131
+ ---------------------------------------------------------------------------
132
+  (0.1ms) rollback transaction
133
+  (0.1ms) begin transaction
425
134
  ------------------------------------------------------------------------------------
426
135
  ModelFromTableGeneratorTest: test_table_name_and_primary_key_is_not_rails_convension
427
136
  ------------------------------------------------------------------------------------
428
-  (0.4ms) ROLLBACK
429
-  (0.3ms) BEGIN
137
+  (0.1ms) rollback transaction
138
+  (0.1ms) begin transaction
430
139
  --------------------------------------------------------------------
431
140
  ModelFromTableGeneratorTest: test_table_name_is_not_rails_convension
432
141
  --------------------------------------------------------------------
433
-  (0.5ms) ROLLBACK
434
- ActiveRecord::SchemaMigration Load (1.8ms) SELECT "schema_migrations".* FROM "schema_migrations"
435
-  (0.5ms) BEGIN
142
+  (0.1ms) rollback transaction
143
+  (0.1ms) begin transaction
436
144
  -------------------------------------------------------
437
145
  ModelFromTableGeneratorTest: test_all_files_are_created
438
146
  -------------------------------------------------------
439
-  (0.5ms) ROLLBACK
440
-  (0.3ms) BEGIN
147
+  (0.1ms) rollback transaction
148
+  (0.1ms) begin transaction
441
149
  ----------------------------------------------------------------
442
150
  ModelFromTableGeneratorTest: test_not_create_schema_migration.rb
443
151
  ----------------------------------------------------------------
444
-  (0.4ms) ROLLBACK
445
-  (0.3ms) BEGIN
152
+  (0.1ms) rollback transaction
153
+  (0.1ms) begin transaction
446
154
  --------------------------------------------------
447
155
  ModelFromTableGeneratorTest: test_rails_convension
448
156
  --------------------------------------------------
449
-  (0.5ms) ROLLBACK
450
-  (0.3ms) BEGIN
157
+  (0.1ms) rollback transaction
158
+  (0.1ms) begin transaction
159
+ ---------------------------------------------------------------------------
160
+ ModelFromTableGeneratorTest: test_set_belongs_to_if_table_has_xxx_id_column
161
+ ---------------------------------------------------------------------------
162
+  (0.1ms) rollback transaction
163
+  (0.1ms) begin transaction
451
164
  ------------------------------------------------------------------------------------
452
165
  ModelFromTableGeneratorTest: test_table_name_and_primary_key_is_not_rails_convension
453
166
  ------------------------------------------------------------------------------------
454
-  (0.4ms) ROLLBACK
455
-  (0.3ms) BEGIN
167
+  (0.0ms) rollback transaction
168
+  (0.1ms) begin transaction
456
169
  --------------------------------------------------------------------
457
170
  ModelFromTableGeneratorTest: test_table_name_is_not_rails_convension
458
171
  --------------------------------------------------------------------
459
-  (0.5ms) ROLLBACK
172
+  (0.0ms) rollback transaction
460
173
   (0.1ms) begin transaction
461
174
  -------------------------------------------------------
462
175
  ModelFromTableGeneratorTest: test_all_files_are_created
463
176
  -------------------------------------------------------
464
177
   (0.1ms) rollback transaction
465
-  (0.0ms) begin transaction
178
+  (0.1ms) begin transaction
466
179
  ----------------------------------------------------------------
467
180
  ModelFromTableGeneratorTest: test_not_create_schema_migration.rb
468
181
  ----------------------------------------------------------------
469
-  (0.1ms) rollback transaction
182
+  (0.0ms) rollback transaction
470
183
   (0.1ms) begin transaction
471
184
  --------------------------------------------------
472
185
  ModelFromTableGeneratorTest: test_rails_convension
473
186
  --------------------------------------------------
474
187
   (0.1ms) rollback transaction
475
188
   (0.0ms) begin transaction
189
+ ---------------------------------------------------------------------------
190
+ ModelFromTableGeneratorTest: test_set_belongs_to_if_table_has_xxx_id_column
191
+ ---------------------------------------------------------------------------
192
+  (0.0ms) rollback transaction
193
+  (0.0ms) begin transaction
476
194
  ------------------------------------------------------------------------------------
477
195
  ModelFromTableGeneratorTest: test_table_name_and_primary_key_is_not_rails_convension
478
196
  ------------------------------------------------------------------------------------
@@ -481,7 +199,7 @@ ModelFromTableGeneratorTest: test_table_name_and_primary_key_is_not_rails_conven
481
199
  --------------------------------------------------------------------
482
200
  ModelFromTableGeneratorTest: test_table_name_is_not_rails_convension
483
201
  --------------------------------------------------------------------
484
-  (0.1ms) rollback transaction
202
+  (0.0ms) rollback transaction
485
203
   (0.1ms) begin transaction
486
204
  -------------------------------------------------------
487
205
  ModelFromTableGeneratorTest: test_all_files_are_created
@@ -497,7 +215,12 @@ ModelFromTableGeneratorTest: test_not_create_schema_migration.rb
497
215
  ModelFromTableGeneratorTest: test_rails_convension
498
216
  --------------------------------------------------
499
217
   (0.1ms) rollback transaction
500
-  (0.0ms) begin transaction
218
+  (0.1ms) begin transaction
219
+ ---------------------------------------------------------------------------
220
+ ModelFromTableGeneratorTest: test_set_belongs_to_if_table_has_xxx_id_column
221
+ ---------------------------------------------------------------------------
222
+  (0.0ms) rollback transaction
223
+  (0.1ms) begin transaction
501
224
  ------------------------------------------------------------------------------------
502
225
  ModelFromTableGeneratorTest: test_table_name_and_primary_key_is_not_rails_convension
503
226
  ------------------------------------------------------------------------------------
@@ -511,104 +234,114 @@ ModelFromTableGeneratorTest: test_table_name_is_not_rails_convension
511
234
  -------------------------------------------------------
512
235
  ModelFromTableGeneratorTest: test_all_files_are_created
513
236
  -------------------------------------------------------
514
-  (0.0ms) SAVEPOINT active_record_1
237
+  (0.1ms) rollback transaction
238
+  (0.0ms) begin transaction
515
239
  ----------------------------------------------------------------
516
240
  ModelFromTableGeneratorTest: test_not_create_schema_migration.rb
517
241
  ----------------------------------------------------------------
518
-  (0.0ms) SAVEPOINT active_record_2
242
+  (0.0ms) rollback transaction
243
+  (0.0ms) begin transaction
519
244
  --------------------------------------------------
520
245
  ModelFromTableGeneratorTest: test_rails_convension
521
246
  --------------------------------------------------
522
-  (0.0ms) SAVEPOINT active_record_3
247
+  (0.0ms) rollback transaction
248
+  (0.0ms) begin transaction
249
+ ---------------------------------------------------------------------------
250
+ ModelFromTableGeneratorTest: test_set_belongs_to_if_table_has_xxx_id_column
251
+ ---------------------------------------------------------------------------
252
+  (0.0ms) rollback transaction
253
+  (0.1ms) begin transaction
523
254
  ------------------------------------------------------------------------------------
524
255
  ModelFromTableGeneratorTest: test_table_name_and_primary_key_is_not_rails_convension
525
256
  ------------------------------------------------------------------------------------
526
-  (0.1ms) SAVEPOINT active_record_4
257
+  (0.1ms) rollback transaction
258
+  (0.1ms) begin transaction
527
259
  --------------------------------------------------------------------
528
260
  ModelFromTableGeneratorTest: test_table_name_is_not_rails_convension
529
261
  --------------------------------------------------------------------
262
+  (0.0ms) rollback transaction
263
+  (1.7ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
264
+  (0.5ms) select sqlite_version(*)
265
+  (1.3ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
266
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
267
+ Migrating to CreateTables (20140728150510)
530
268
   (0.1ms) begin transaction
269
+  (0.4ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
270
+  (0.2ms) CREATE TABLE "company" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
271
+  (0.1ms) CREATE TABLE "legacy_table" ("code" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
272
+  (0.2ms) CREATE TABLE "song" ("song_code" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "user_id" integer) 
273
+ SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140728150510"]]
274
+  (1.2ms) commit transaction
275
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
276
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
277
+  (0.1ms) begin transaction
531
278
  -------------------------------------------------------
532
279
  ModelFromTableGeneratorTest: test_all_files_are_created
533
280
  -------------------------------------------------------
534
-  (0.1ms) rollback transaction
535
-  (0.1ms) begin transaction
281
+  (0.1ms) rollback transaction
282
+  (0.1ms) begin transaction
536
283
  ----------------------------------------------------------------
537
284
  ModelFromTableGeneratorTest: test_not_create_schema_migration.rb
538
285
  ----------------------------------------------------------------
539
-  (0.0ms) rollback transaction
540
-  (0.1ms) begin transaction
286
+  (0.1ms) rollback transaction
287
+  (0.1ms) begin transaction
541
288
  --------------------------------------------------
542
289
  ModelFromTableGeneratorTest: test_rails_convension
543
290
  --------------------------------------------------
544
-  (0.0ms) rollback transaction
545
-  (0.1ms) begin transaction
291
+  (0.1ms) rollback transaction
292
+  (0.1ms) begin transaction
293
+ ---------------------------------------------------------------------------
294
+ ModelFromTableGeneratorTest: test_set_belongs_to_if_table_has_xxx_id_column
295
+ ---------------------------------------------------------------------------
296
+  (0.1ms) rollback transaction
297
+  (0.1ms) begin transaction
546
298
  ------------------------------------------------------------------------------------
547
299
  ModelFromTableGeneratorTest: test_table_name_and_primary_key_is_not_rails_convension
548
300
  ------------------------------------------------------------------------------------
549
-  (0.0ms) rollback transaction
550
-  (0.1ms) begin transaction
301
+  (0.1ms) rollback transaction
302
+  (0.1ms) begin transaction
551
303
  --------------------------------------------------------------------
552
304
  ModelFromTableGeneratorTest: test_table_name_is_not_rails_convension
553
305
  --------------------------------------------------------------------
554
-  (0.1ms) rollback transaction
555
-  (0.1ms) begin transaction
306
+  (0.1ms) rollback transaction
307
+ ActiveRecord::SchemaMigration Load (0.6ms) SELECT "schema_migrations".* FROM "schema_migrations"
308
+  (0.1ms) begin transaction
556
309
  -------------------------------------------------------
557
310
  ModelFromTableGeneratorTest: test_all_files_are_created
558
311
  -------------------------------------------------------
559
-  (0.1ms) rollback transaction
560
-  (0.0ms) begin transaction
312
+  (0.1ms) rollback transaction
313
+  (0.1ms) begin transaction
561
314
  ----------------------------------------------------------------
562
315
  ModelFromTableGeneratorTest: test_not_create_schema_migration.rb
563
316
  ----------------------------------------------------------------
564
-  (0.0ms) rollback transaction
565
-  (0.0ms) begin transaction
317
+  (0.1ms) rollback transaction
318
+  (0.0ms) begin transaction
566
319
  --------------------------------------------------
567
320
  ModelFromTableGeneratorTest: test_rails_convension
568
321
  --------------------------------------------------
569
-  (0.0ms) rollback transaction
570
-  (0.0ms) begin transaction
322
+  (0.1ms) rollback transaction
323
+  (0.1ms) begin transaction
324
+ ---------------------------------------------------------------------------
325
+ ModelFromTableGeneratorTest: test_set_belongs_to_if_table_has_xxx_id_column
326
+ ---------------------------------------------------------------------------
327
+  (0.2ms) rollback transaction
328
+  (0.1ms) begin transaction
571
329
  ------------------------------------------------------------------------------------
572
330
  ModelFromTableGeneratorTest: test_table_name_and_primary_key_is_not_rails_convension
573
331
  ------------------------------------------------------------------------------------
574
-  (0.0ms) rollback transaction
575
-  (0.0ms) begin transaction
332
+  (0.1ms) rollback transaction
333
+  (0.0ms) begin transaction
576
334
  --------------------------------------------------------------------
577
335
  ModelFromTableGeneratorTest: test_table_name_is_not_rails_convension
578
336
  --------------------------------------------------------------------
579
-  (0.1ms) rollback transaction
580
-  (2.5ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
581
-  (0.1ms) select sqlite_version(*)
582
-  (1.3ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
583
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
584
- Migrating to CreateTables (20140728150510)
585
-  (0.1ms) begin transaction
586
-  (0.1ms) rollback transaction
587
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
588
- Migrating to CreateTables (20140728150510)
589
-  (0.1ms) begin transaction
590
-  (0.5ms) CREATE TABLE "tme_profiles" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
591
-  (0.2ms) CREATE TABLE "company" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
592
-  (0.1ms) CREATE TABLE "some_legacy_table" ("code" varchar(255)) 
593
-  (0.3ms) ALTER TABLE some_legacy_table ADD PRIMARY KEY (code)
594
- SQLite3::SQLException: near "PRIMARY": syntax error: ALTER TABLE some_legacy_table ADD PRIMARY KEY (code)
595
-  (1.8ms) rollback transaction
337
+  (0.1ms) rollback transaction
596
338
  ActiveRecord::SchemaMigration Load (0.6ms) SELECT "schema_migrations".* FROM "schema_migrations"
597
- Migrating to CreateTables (20140728150510)
598
-  (0.1ms) begin transaction
599
-  (0.5ms) CREATE TABLE "tme_profiles" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
600
-  (0.1ms) CREATE TABLE "company" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
601
-  (0.1ms) CREATE TABLE "some_legacy_table" ("code" varchar(255)) 
602
- SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140728150510"]]
603
-  (1.3ms) commit transaction
604
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
605
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
606
339
   (0.1ms) begin transaction
607
340
  -------------------------------------------------------
608
341
  ModelFromTableGeneratorTest: test_all_files_are_created
609
342
  -------------------------------------------------------
610
343
   (0.1ms) rollback transaction
611
-  (0.1ms) begin transaction
344
+  (0.0ms) begin transaction
612
345
  ----------------------------------------------------------------
613
346
  ModelFromTableGeneratorTest: test_not_create_schema_migration.rb
614
347
  ----------------------------------------------------------------
@@ -619,6 +352,11 @@ ModelFromTableGeneratorTest: test_rails_convension
619
352
  --------------------------------------------------
620
353
   (0.1ms) rollback transaction
621
354
   (0.1ms) begin transaction
355
+ ---------------------------------------------------------------------------
356
+ ModelFromTableGeneratorTest: test_set_belongs_to_if_table_has_xxx_id_column
357
+ ---------------------------------------------------------------------------
358
+  (0.1ms) rollback transaction
359
+  (0.1ms) begin transaction
622
360
  ------------------------------------------------------------------------------------
623
361
  ModelFromTableGeneratorTest: test_table_name_and_primary_key_is_not_rails_convension
624
362
  ------------------------------------------------------------------------------------
@@ -628,23 +366,7 @@ ModelFromTableGeneratorTest: test_table_name_and_primary_key_is_not_rails_conven
628
366
  ModelFromTableGeneratorTest: test_table_name_is_not_rails_convension
629
367
  --------------------------------------------------------------------
630
368
   (0.1ms) rollback transaction
631
-  (1.9ms) DROP TABLE "company"
632
-  (1.0ms) CREATE TABLE "company" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
633
-  (1.1ms) DROP TABLE "some_legacy_table"
634
-  (1.1ms) CREATE TABLE "some_legacy_table" ("code" varchar(255))
635
-  (1.0ms) DROP TABLE "tme_profiles"
636
-  (1.6ms) CREATE TABLE "tme_profiles" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
637
-  (0.1ms) SELECT version FROM "schema_migrations"
638
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
639
-  (2.4ms) DROP TABLE "company"
640
-  (1.3ms) CREATE TABLE "company" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
641
-  (1.0ms) DROP TABLE "some_legacy_table"
642
-  (1.0ms) CREATE TABLE "some_legacy_table" ("code" varchar(255))
643
-  (1.2ms) DROP TABLE "tme_profiles"
644
-  (1.3ms) CREATE TABLE "tme_profiles" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
645
-  (0.2ms) SELECT version FROM "schema_migrations"
646
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
647
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
369
+ ActiveRecord::SchemaMigration Load (0.5ms) SELECT "schema_migrations".* FROM "schema_migrations"
648
370
   (0.1ms) begin transaction
649
371
  -------------------------------------------------------
650
372
  ModelFromTableGeneratorTest: test_all_files_are_created
@@ -654,36 +376,33 @@ ModelFromTableGeneratorTest: test_all_files_are_created
654
376
  ----------------------------------------------------------------
655
377
  ModelFromTableGeneratorTest: test_not_create_schema_migration.rb
656
378
  ----------------------------------------------------------------
657
-  (0.1ms) rollback transaction
379
+  (0.2ms) rollback transaction
658
380
   (0.1ms) begin transaction
659
381
  --------------------------------------------------
660
382
  ModelFromTableGeneratorTest: test_rails_convension
661
383
  --------------------------------------------------
662
384
   (0.1ms) rollback transaction
663
385
   (0.1ms) begin transaction
386
+ ---------------------------------------------------------------------------
387
+ ModelFromTableGeneratorTest: test_set_belongs_to_if_table_has_xxx_id_column
388
+ ---------------------------------------------------------------------------
389
+  (0.1ms) rollback transaction
390
+  (0.1ms) begin transaction
664
391
  ------------------------------------------------------------------------------------
665
392
  ModelFromTableGeneratorTest: test_table_name_and_primary_key_is_not_rails_convension
666
393
  ------------------------------------------------------------------------------------
667
394
   (0.1ms) rollback transaction
668
-  (0.0ms) begin transaction
395
+  (0.1ms) begin transaction
669
396
  --------------------------------------------------------------------
670
397
  ModelFromTableGeneratorTest: test_table_name_is_not_rails_convension
671
398
  --------------------------------------------------------------------
672
399
   (0.1ms) rollback transaction
673
-  (2.6ms) DROP TABLE "company"
674
-  (1.1ms) CREATE TABLE "company" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
675
-  (1.1ms) DROP TABLE "some_legacy_table"
676
-  (1.0ms) CREATE TABLE "some_legacy_table" ("code" varchar(255))
677
-  (1.1ms) DROP TABLE "tme_profiles"
678
-  (1.8ms) CREATE TABLE "tme_profiles" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
679
-  (0.1ms) SELECT version FROM "schema_migrations"
680
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
681
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
400
+ ActiveRecord::SchemaMigration Load (0.5ms) SELECT "schema_migrations".* FROM "schema_migrations"
682
401
   (0.1ms) begin transaction
683
402
  -------------------------------------------------------
684
403
  ModelFromTableGeneratorTest: test_all_files_are_created
685
404
  -------------------------------------------------------
686
-  (0.1ms) rollback transaction
405
+  (0.2ms) rollback transaction
687
406
   (0.1ms) begin transaction
688
407
  ----------------------------------------------------------------
689
408
  ModelFromTableGeneratorTest: test_not_create_schema_migration.rb
@@ -695,6 +414,11 @@ ModelFromTableGeneratorTest: test_rails_convension
695
414
  --------------------------------------------------
696
415
   (0.1ms) rollback transaction
697
416
   (0.1ms) begin transaction
417
+ ---------------------------------------------------------------------------
418
+ ModelFromTableGeneratorTest: test_set_belongs_to_if_table_has_xxx_id_column
419
+ ---------------------------------------------------------------------------
420
+  (0.1ms) rollback transaction
421
+  (0.1ms) begin transaction
698
422
  ------------------------------------------------------------------------------------
699
423
  ModelFromTableGeneratorTest: test_table_name_and_primary_key_is_not_rails_convension
700
424
  ------------------------------------------------------------------------------------
@@ -704,16 +428,7 @@ ModelFromTableGeneratorTest: test_table_name_and_primary_key_is_not_rails_conven
704
428
  ModelFromTableGeneratorTest: test_table_name_is_not_rails_convension
705
429
  --------------------------------------------------------------------
706
430
   (0.1ms) rollback transaction
707
-  (2.7ms) CREATE TABLE "company" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
708
-  (1.1ms) CREATE TABLE "some_legacy_table" ("code" varchar(255))
709
-  (1.2ms) CREATE TABLE "tme_profiles" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
710
-  (1.3ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
711
-  (0.1ms) select sqlite_version(*)
712
-  (1.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
713
-  (0.1ms) SELECT version FROM "schema_migrations"
714
-  (1.4ms) INSERT INTO "schema_migrations" (version) VALUES ('20140728150510')
715
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
716
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
431
+ ActiveRecord::SchemaMigration Load (0.6ms) SELECT "schema_migrations".* FROM "schema_migrations"
717
432
   (0.1ms) begin transaction
718
433
  -------------------------------------------------------
719
434
  ModelFromTableGeneratorTest: test_all_files_are_created
@@ -729,25 +444,21 @@ ModelFromTableGeneratorTest: test_not_create_schema_migration.rb
729
444
  ModelFromTableGeneratorTest: test_rails_convension
730
445
  --------------------------------------------------
731
446
   (0.1ms) rollback transaction
732
-  (0.0ms) begin transaction
447
+  (0.1ms) begin transaction
448
+ ---------------------------------------------------------------------------
449
+ ModelFromTableGeneratorTest: test_set_belongs_to_if_table_has_xxx_id_column
450
+ ---------------------------------------------------------------------------
451
+  (0.1ms) rollback transaction
452
+  (0.1ms) begin transaction
733
453
  ------------------------------------------------------------------------------------
734
454
  ModelFromTableGeneratorTest: test_table_name_and_primary_key_is_not_rails_convension
735
455
  ------------------------------------------------------------------------------------
736
456
   (0.1ms) rollback transaction
737
-  (0.1ms) begin transaction
457
+  (0.0ms) begin transaction
738
458
  --------------------------------------------------------------------
739
459
  ModelFromTableGeneratorTest: test_table_name_is_not_rails_convension
740
460
  --------------------------------------------------------------------
741
461
   (0.1ms) rollback transaction
742
-  (1.1ms) CREATE TABLE "company" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
743
-  (1.0ms) CREATE TABLE "some_legacy_table" ("code" varchar(255))
744
-  (1.1ms) CREATE TABLE "tme_profiles" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
745
-  (1.1ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
746
-  (0.1ms) select sqlite_version(*)
747
-  (0.9ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
748
-  (0.1ms) SELECT version FROM "schema_migrations"
749
-  (0.9ms) INSERT INTO "schema_migrations" (version) VALUES ('20140728150510')
750
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
751
462
  ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
752
463
   (0.1ms) begin transaction
753
464
  -------------------------------------------------------
@@ -763,6 +474,11 @@ ModelFromTableGeneratorTest: test_not_create_schema_migration.rb
763
474
  --------------------------------------------------
764
475
  ModelFromTableGeneratorTest: test_rails_convension
765
476
  --------------------------------------------------
477
+  (0.2ms) rollback transaction
478
+  (0.1ms) begin transaction
479
+ ---------------------------------------------------------------------------
480
+ ModelFromTableGeneratorTest: test_set_belongs_to_if_table_has_xxx_id_column
481
+ ---------------------------------------------------------------------------
766
482
   (0.1ms) rollback transaction
767
483
   (0.1ms) begin transaction
768
484
  ------------------------------------------------------------------------------------
@@ -774,152 +490,59 @@ ModelFromTableGeneratorTest: test_table_name_and_primary_key_is_not_rails_conven
774
490
  ModelFromTableGeneratorTest: test_table_name_is_not_rails_convension
775
491
  --------------------------------------------------------------------
776
492
   (0.1ms) rollback transaction
777
-  (2.6ms) CREATE TABLE "company" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
778
-  (1.1ms) CREATE TABLE "some_legacy_table" ("code" varchar(255))
779
-  (1.2ms) CREATE TABLE "tme_profiles" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
780
-  (1.2ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
781
-  (0.1ms) select sqlite_version(*)
782
-  (1.2ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
783
-  (0.2ms) SELECT version FROM "schema_migrations"
784
-  (1.1ms) INSERT INTO "schema_migrations" (version) VALUES ('20140728150510')
785
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
786
-  (2.6ms) CREATE TABLE "company" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
787
-  (1.0ms) CREATE TABLE "some_legacy_table" ("code" varchar(255))
788
-  (1.2ms) CREATE TABLE "tme_profiles" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
789
-  (1.3ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
790
-  (0.1ms) select sqlite_version(*)
791
-  (1.2ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
792
-  (0.1ms) SELECT version FROM "schema_migrations"
793
-  (1.1ms) INSERT INTO "schema_migrations" (version) VALUES ('20140728150510')
794
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
795
-  (2.5ms) CREATE TABLE "company" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
796
-  (1.1ms) CREATE TABLE "some_legacy_table" ("code" varchar(255))
797
-  (1.1ms) CREATE TABLE "tme_profiles" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
798
-  (1.0ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
799
-  (0.1ms) select sqlite_version(*)
800
-  (1.3ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
801
-  (0.1ms) SELECT version FROM "schema_migrations"
802
-  (1.0ms) INSERT INTO "schema_migrations" (version) VALUES ('20140728150510')
803
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
804
-  (2.3ms) CREATE TABLE "company" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
805
-  (1.1ms) CREATE TABLE "some_legacy_table" ("code" varchar(255))
806
-  (1.1ms) CREATE TABLE "tme_profiles" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
807
-  (1.1ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
808
-  (0.1ms) select sqlite_version(*)
809
-  (1.0ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
810
-  (0.1ms) SELECT version FROM "schema_migrations"
811
-  (1.2ms) INSERT INTO "schema_migrations" (version) VALUES ('20140728150510')
812
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
813
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
814
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
815
- Migrating to CreateTables (20140728150510)
816
-  (0.1ms) begin transaction
817
-  (0.5ms) DROP TABLE "some_legacy_table"
818
-  (1.0ms) DROP TABLE "company"
819
-  (0.2ms) DROP TABLE "tme_profiles"
820
- SQL (0.2ms) DELETE FROM "schema_migrations" WHERE "schema_migrations"."version" = '20140728150510'
821
-  (1.4ms) commit transaction
822
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
823
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
824
- Migrating to CreateTables (20140728150510)
493
+ ActiveRecord::SchemaMigration Load (0.6ms) SELECT "schema_migrations".* FROM "schema_migrations"
825
494
   (0.1ms) begin transaction
826
-  (0.5ms) CREATE TABLE "tme_profiles" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
827
-  (0.2ms) CREATE TABLE "company" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
828
-  (1.7ms) rollback transaction
829
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
830
- Migrating to CreateTables (20140728150510)
495
+ -------------------------------------------------------
496
+ ModelFromTableGeneratorTest: test_all_files_are_created
497
+ -------------------------------------------------------
498
+  (0.1ms) rollback transaction
831
499
   (0.1ms) begin transaction
832
-  (0.5ms) CREATE TABLE "tme_profiles" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
833
-  (0.2ms) CREATE TABLE "company" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
834
-  (0.1ms) CREATE TABLE "some_legacy_table" ("code" varchar(255)) 
835
- SQL (0.5ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140728150510"]]
836
-  (1.3ms) commit transaction
837
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
838
- ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
839
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
840
- Migrating to CreateTables (20140728150510)
841
-  (0.1ms) begin transaction
842
-  (0.4ms) DROP TABLE "some_legacy_table"
843
-  (1.0ms) DROP TABLE "company"
844
-  (0.2ms) DROP TABLE "tme_profiles"
845
- SQL (0.2ms) DELETE FROM "schema_migrations" WHERE "schema_migrations"."version" = '20140728150510'
846
-  (1.3ms) commit transaction
847
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
848
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
849
- Migrating to CreateTables (20140728150510)
500
+ ----------------------------------------------------------------
501
+ ModelFromTableGeneratorTest: test_not_create_schema_migration.rb
502
+ ----------------------------------------------------------------
503
+  (0.1ms) rollback transaction
850
504
   (0.1ms) begin transaction
851
-  (0.4ms) CREATE TABLE "tme_profiles" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
852
-  (0.2ms) CREATE TABLE "company" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
853
-  (0.2ms) CREATE TABLE "some_legacy_table" () 
854
- SQLite3::SQLException: near ")": syntax error: CREATE TABLE "some_legacy_table" ()
855
-  (1.7ms) rollback transaction
856
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
857
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
858
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
859
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
860
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
861
- Migrating to CreateTables (20140728150510)
505
+ --------------------------------------------------
506
+ ModelFromTableGeneratorTest: test_rails_convension
507
+ --------------------------------------------------
508
+  (0.1ms) rollback transaction
862
509
   (0.1ms) begin transaction
863
-  (0.4ms) CREATE TABLE "tme_profiles" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
864
-  (0.2ms) CREATE TABLE "company" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
865
-  (0.1ms) CREATE TABLE "some_legacy_table" ("code" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
866
- SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140728150510"]]
867
-  (2.5ms) commit transaction
868
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
869
-  (3.4ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
870
-  (0.1ms) select sqlite_version(*)
871
-  (1.3ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
872
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
873
- Migrating to CreateTables (20140728150510)
874
-  (0.1ms) begin transaction
875
-  (0.4ms) CREATE TABLE "tme_profiles" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
876
-  (0.1ms) CREATE TABLE "company" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
877
-  (0.2ms) CREATE TABLE "some_legacy_table" ("code" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
878
- SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140728150510"]]
879
-  (1.2ms) commit transaction
880
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
881
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
882
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
883
- Migrating to CreateTables (20140728150510)
884
-  (0.1ms) begin transaction
885
-  (0.4ms) DROP TABLE "some_legacy_table"
886
-  (0.9ms) DROP TABLE "company"
887
-  (0.2ms) DROP TABLE "tme_profiles"
888
- SQL (0.2ms) DELETE FROM "schema_migrations" WHERE "schema_migrations"."version" = '20140728150510'
889
-  (4.3ms) commit transaction
890
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
891
- ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
892
- Migrating to CreateTables (20140728150510)
510
+ ---------------------------------------------------------------------------
511
+ ModelFromTableGeneratorTest: test_set_belongs_to_if_table_has_xxx_id_column
512
+ ---------------------------------------------------------------------------
513
+  (0.1ms) rollback transaction
893
514
   (0.1ms) begin transaction
894
-  (0.5ms) CREATE TABLE "tme_profiles" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
895
-  (0.2ms) CREATE TABLE "company" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
896
-  (1.6ms) rollback transaction
897
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
898
- Migrating to CreateTables (20140728150510)
515
+ ------------------------------------------------------------------------------------
516
+ ModelFromTableGeneratorTest: test_table_name_and_primary_key_is_not_rails_convension
517
+ ------------------------------------------------------------------------------------
518
+  (0.1ms) rollback transaction
899
519
   (0.1ms) begin transaction
900
-  (0.5ms) CREATE TABLE "tme_profiles" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
901
-  (0.2ms) CREATE TABLE "company" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
902
-  (0.1ms) CREATE TABLE "some_legacy_table" ("code" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
903
- SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140728150510"]]
904
-  (2.5ms) commit transaction
905
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
906
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
520
+ --------------------------------------------------------------------
521
+ ModelFromTableGeneratorTest: test_table_name_is_not_rails_convension
522
+ --------------------------------------------------------------------
523
+  (0.1ms) rollback transaction
524
+ ActiveRecord::SchemaMigration Load (0.7ms) SELECT "schema_migrations".* FROM "schema_migrations"
907
525
   (0.1ms) begin transaction
908
526
  -------------------------------------------------------
909
527
  ModelFromTableGeneratorTest: test_all_files_are_created
910
528
  -------------------------------------------------------
911
529
   (0.1ms) rollback transaction
912
-  (0.1ms) begin transaction
530
+  (0.2ms) begin transaction
913
531
  ----------------------------------------------------------------
914
532
  ModelFromTableGeneratorTest: test_not_create_schema_migration.rb
915
533
  ----------------------------------------------------------------
916
-  (0.1ms) rollback transaction
534
+  (0.2ms) rollback transaction
917
535
   (0.1ms) begin transaction
918
536
  --------------------------------------------------
919
537
  ModelFromTableGeneratorTest: test_rails_convension
920
538
  --------------------------------------------------
921
539
   (0.1ms) rollback transaction
922
540
   (0.1ms) begin transaction
541
+ ---------------------------------------------------------------------------
542
+ ModelFromTableGeneratorTest: test_set_belongs_to_if_table_has_xxx_id_column
543
+ ---------------------------------------------------------------------------
544
+  (0.1ms) rollback transaction
545
+  (0.1ms) begin transaction
923
546
  ------------------------------------------------------------------------------------
924
547
  ModelFromTableGeneratorTest: test_table_name_and_primary_key_is_not_rails_convension
925
548
  ------------------------------------------------------------------------------------
@@ -929,7 +552,7 @@ ModelFromTableGeneratorTest: test_table_name_and_primary_key_is_not_rails_conven
929
552
  ModelFromTableGeneratorTest: test_table_name_is_not_rails_convension
930
553
  --------------------------------------------------------------------
931
554
   (0.1ms) rollback transaction
932
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
555
+ ActiveRecord::SchemaMigration Load (0.5ms) SELECT "schema_migrations".* FROM "schema_migrations"
933
556
   (0.1ms) begin transaction
934
557
  -------------------------------------------------------
935
558
  ModelFromTableGeneratorTest: test_all_files_are_created
@@ -947,6 +570,11 @@ ModelFromTableGeneratorTest: test_rails_convension
947
570
   (0.1ms) rollback transaction
948
571
   (0.1ms) begin transaction
949
572
  ------------------------------------------------------------------------------------
573
+ ModelFromTableGeneratorTest: test_set_`belongs_to_:xxx`_if_table_has_`xxx_id`_column
574
+ ------------------------------------------------------------------------------------
575
+  (0.1ms) rollback transaction
576
+  (0.1ms) begin transaction
577
+ ------------------------------------------------------------------------------------
950
578
  ModelFromTableGeneratorTest: test_table_name_and_primary_key_is_not_rails_convension
951
579
  ------------------------------------------------------------------------------------
952
580
   (0.1ms) rollback transaction
@@ -955,19 +583,7 @@ ModelFromTableGeneratorTest: test_table_name_and_primary_key_is_not_rails_conven
955
583
  ModelFromTableGeneratorTest: test_table_name_is_not_rails_convension
956
584
  --------------------------------------------------------------------
957
585
   (0.1ms) rollback transaction
958
-  (3.4ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
959
-  (0.1ms) select sqlite_version(*)
960
-  (1.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
961
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
962
- Migrating to CreateTables (20140728150510)
963
-  (0.1ms) begin transaction
964
-  (0.4ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
965
-  (0.1ms) CREATE TABLE "company" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
966
-  (0.2ms) CREATE TABLE "legacy_table" ("code" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
967
- SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140728150510"]]
968
-  (1.2ms) commit transaction
969
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
970
- ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
586
+ ActiveRecord::SchemaMigration Load (0.7ms) SELECT "schema_migrations".* FROM "schema_migrations"
971
587
   (0.1ms) begin transaction
972
588
  -------------------------------------------------------
973
589
  ModelFromTableGeneratorTest: test_all_files_are_created
@@ -985,6 +601,11 @@ ModelFromTableGeneratorTest: test_rails_convension
985
601
   (0.1ms) rollback transaction
986
602
   (0.1ms) begin transaction
987
603
  ------------------------------------------------------------------------------------
604
+ ModelFromTableGeneratorTest: test_set_`belongs_to_:xxx`_if_table_has_`xxx_id`_column
605
+ ------------------------------------------------------------------------------------
606
+  (0.1ms) rollback transaction
607
+  (0.1ms) begin transaction
608
+ ------------------------------------------------------------------------------------
988
609
  ModelFromTableGeneratorTest: test_table_name_and_primary_key_is_not_rails_convension
989
610
  ------------------------------------------------------------------------------------
990
611
   (0.1ms) rollback transaction
@@ -993,7 +614,7 @@ ModelFromTableGeneratorTest: test_table_name_and_primary_key_is_not_rails_conven
993
614
  ModelFromTableGeneratorTest: test_table_name_is_not_rails_convension
994
615
  --------------------------------------------------------------------
995
616
   (0.1ms) rollback transaction
996
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
617
+ ActiveRecord::SchemaMigration Load (0.5ms) SELECT "schema_migrations".* FROM "schema_migrations"
997
618
   (0.1ms) begin transaction
998
619
  -------------------------------------------------------
999
620
  ModelFromTableGeneratorTest: test_all_files_are_created
@@ -1011,15 +632,33 @@ ModelFromTableGeneratorTest: test_rails_convension
1011
632
   (0.1ms) rollback transaction
1012
633
   (0.1ms) begin transaction
1013
634
  ------------------------------------------------------------------------------------
635
+ ModelFromTableGeneratorTest: test_set_`belongs_to_:foo`_if_table_has_`foo_id`_column
636
+ ------------------------------------------------------------------------------------
637
+  (0.2ms) rollback transaction
638
+  (0.1ms) begin transaction
639
+ ------------------------------------------------------------------------------------
1014
640
  ModelFromTableGeneratorTest: test_table_name_and_primary_key_is_not_rails_convension
1015
641
  ------------------------------------------------------------------------------------
1016
642
   (0.1ms) rollback transaction
1017
-  (0.2ms) begin transaction
643
+  (0.1ms) begin transaction
1018
644
  --------------------------------------------------------------------
1019
645
  ModelFromTableGeneratorTest: test_table_name_is_not_rails_convension
1020
646
  --------------------------------------------------------------------
1021
647
   (0.1ms) rollback transaction
1022
- ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
648
+  (1.1ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
649
+  (0.4ms) select sqlite_version(*)
650
+  (0.9ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
651
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
652
+ Migrating to CreateTables (20140728150510)
653
+  (0.1ms) begin transaction
654
+  (0.4ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
655
+  (0.2ms) CREATE TABLE "company" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
656
+  (0.2ms) CREATE TABLE "legacy_table" ("code" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
657
+  (0.2ms) CREATE TABLE "song" ("song_code" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "user_id" integer, "type" varchar(255)) 
658
+ SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140728150510"]]
659
+  (1.0ms) commit transaction
660
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
661
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
1023
662
   (0.1ms) begin transaction
1024
663
  -------------------------------------------------------
1025
664
  ModelFromTableGeneratorTest: test_all_files_are_created
@@ -1037,6 +676,11 @@ ModelFromTableGeneratorTest: test_rails_convension
1037
676
   (0.1ms) rollback transaction
1038
677
   (0.1ms) begin transaction
1039
678
  ------------------------------------------------------------------------------------
679
+ ModelFromTableGeneratorTest: test_set_`belongs_to_:foo`_if_table_has_`foo_id`_column
680
+ ------------------------------------------------------------------------------------
681
+  (0.1ms) rollback transaction
682
+  (0.1ms) begin transaction
683
+ ------------------------------------------------------------------------------------
1040
684
  ModelFromTableGeneratorTest: test_table_name_and_primary_key_is_not_rails_convension
1041
685
  ------------------------------------------------------------------------------------
1042
686
   (0.1ms) rollback transaction