mini_record 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -0
- data/lib/mini_record/auto_schema.rb +9 -2
- data/lib/mini_record/version.rb +1 -1
- data/test/test_mini_record.rb +8 -0
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfb798464fea4709be8710a161550d3f4cdf1371
|
4
|
+
data.tar.gz: d2bd9f1fa0fbe58af774dd5a7b66812603a9e358
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d143593162f47be6b2824ce36e47d1b9b2b46b7a84225ffd2bc4e6628f443407866cde9a3d8a1b04a36638ce871c2059141f2899ab61d4f763171ccfb9ad353
|
7
|
+
data.tar.gz: 855af276975d4b394fd9563c6b219fbe61b860e9b1e4aca57b8fe615158df45274ac48171e95f4c7aea01a73c5ded63bbe4e8397f8ddf88d753059b07cb54fc1
|
data/README.md
CHANGED
@@ -260,6 +260,17 @@ class Fox < ActiveRecord::Base
|
|
260
260
|
end
|
261
261
|
```
|
262
262
|
|
263
|
+
### Passing options to Create Table
|
264
|
+
|
265
|
+
If you need to pass particular options to your `CREATE TABLE` statement, you can do so with `create_table` in the Model:
|
266
|
+
|
267
|
+
```ruby
|
268
|
+
class Fox < ActiveRecord::Base
|
269
|
+
create_table :options => 'ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci'
|
270
|
+
field :foo
|
271
|
+
end
|
272
|
+
```
|
273
|
+
|
263
274
|
## Contributors
|
264
275
|
|
265
276
|
A special thanks to all who have contributed in this project:
|
@@ -59,6 +59,10 @@ module MiniRecord
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
+
def create_table_options
|
63
|
+
@create_table_options ||= []
|
64
|
+
end
|
65
|
+
|
62
66
|
def rename_fields
|
63
67
|
@rename_fields ||= {}
|
64
68
|
end
|
@@ -143,6 +147,10 @@ module MiniRecord
|
|
143
147
|
table_definition
|
144
148
|
end
|
145
149
|
|
150
|
+
def create_table(*options)
|
151
|
+
@create_table_options = options
|
152
|
+
end
|
153
|
+
|
146
154
|
def add_index(column_name, options={})
|
147
155
|
index_name = connection.index_name(table_name, :column => column_name)
|
148
156
|
indexes[index_name] = options.merge(:column => column_name) unless indexes.key?(index_name)
|
@@ -209,10 +217,9 @@ module MiniRecord
|
|
209
217
|
else
|
210
218
|
# If table doesn't exist, create it
|
211
219
|
unless connection.tables.include?(table_name)
|
212
|
-
# TODO: create_table options
|
213
220
|
class << connection; attr_accessor :table_definition; end unless connection.respond_to?(:table_definition=)
|
214
221
|
connection.table_definition = table_definition
|
215
|
-
connection.create_table(table_name)
|
222
|
+
connection.create_table(table_name, *create_table_options)
|
216
223
|
connection.table_definition = init_table_definition(connection)
|
217
224
|
end
|
218
225
|
|
data/lib/mini_record/version.rb
CHANGED
data/test/test_mini_record.rb
CHANGED
@@ -887,4 +887,12 @@ describe MiniRecord do
|
|
887
887
|
assert_match '', Foo.queries
|
888
888
|
|
889
889
|
end
|
890
|
+
|
891
|
+
it 'accepts create_table options' do
|
892
|
+
class Foo < ActiveRecord::Base
|
893
|
+
create_table options: "extra options"
|
894
|
+
end
|
895
|
+
Foo.auto_upgrade! rescue nil # eat the exception from invalid options
|
896
|
+
assert_match /CREATE TABLE.* extra options\Z/, Foo.queries
|
897
|
+
end
|
890
898
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mini_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Davide D'Agostino
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10
|
11
|
+
date: 2014-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -74,4 +74,3 @@ test_files:
|
|
74
74
|
- test/helper.rb
|
75
75
|
- test/models.rb
|
76
76
|
- test/test_mini_record.rb
|
77
|
-
has_rdoc:
|