Module: FileBlobs::ActiveRecordMigrationExtensions
- Defined in:
- lib/file_blobs_rails/active_record_migration_extensions.rb
Overview
Module mixed into ActiveRecord::Migration.
Instance Method Summary collapse
-
#create_file_blobs_table(table_name = :file_blobs, options = {}, &block) ⇒ Object
Creates the table used to hold file blobs.
Instance Method Details
#create_file_blobs_table(table_name = :file_blobs, options = {}, &block) ⇒ Object
Creates the table used to hold file blobs.
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/file_blobs_rails/active_record_migration_extensions.rb', line 13 def create_file_blobs_table(table_name = :file_blobs, = {}, &block) blob_limit = [:blob_limit] || 1.megabyte create_table table_name, id: false do |t| t.primary_key :id, :string, null: false, limit: 48 t.binary :data, null: false, limit: blob_limit # Block capturing and calling is a bit slower than using yield. This is # not a concern because migrations aren't run in tight loops. block.call t end end |