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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 09d1ec6c447a806ef8ecc9c33e51c52404ccc948
4
- data.tar.gz: 23f2145d50bfc6b57bd3517af5312b9ca57d04fa
3
+ metadata.gz: cfb798464fea4709be8710a161550d3f4cdf1371
4
+ data.tar.gz: d2bd9f1fa0fbe58af774dd5a7b66812603a9e358
5
5
  SHA512:
6
- metadata.gz: b0a1daa513f1d05437be824e33672092e79b699848678dbafc9c743904694aa83c079caa20d770862311e39bf6ab82f0b7bcc78af9bb72b33d7aac847e18c2ad
7
- data.tar.gz: ba06f494683ca8028b95985cc2ee9a7735b25d01d497f5fb6d47f92fc065881b17312f058a0b947777d128e5d091c9a529249f9c094453f422453225d365f28b
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
 
@@ -1,3 +1,3 @@
1
1
  module MiniRecord
2
- VERSION = "0.4.2"
2
+ VERSION = "0.4.3"
3
3
  end
@@ -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.2
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-04 00:00:00.000000000 Z
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: