module Skr::DB::TableFields
Public Instance Methods
skr_code_identifier()
click to toggle source
# File lib/skr/db/migration_helpers.rb, line 9 def skr_code_identifier column( :code, :string, :null=>false ) skr_extra_indexes['code'] = {} end
skr_currency( names, options )
click to toggle source
# File lib/skr/db/migration_helpers.rb, line 33 def skr_currency( names, options ) options[ :precision ] ||= 15 options[ :scale ] ||= 2 column( names, :decimal, options ) end
skr_extra_indexes()
click to toggle source
# File lib/skr/db/migration_helpers.rb, line 59 def skr_extra_indexes @skr_extra_indexs ||= {} end
skr_foreign_keys()
click to toggle source
# File lib/skr/db/migration_helpers.rb, line 55 def skr_foreign_keys @skr_foreign_keys ||= {} end
skr_reference( to_table, *args )
click to toggle source
An skr_reference
combines a belongs_to / has_one column with a postgresql foreign key reference.
# File lib/skr/db/migration_helpers.rb, line 41 def skr_reference( to_table, *args ) options = args.extract_options! options[:column] ||= to_table.to_s + '_id' column( options[:column], (options[:type] || :integer), :null=>options[:null] || false ) to_table = options[:to_table] if options.has_key? :to_table if options[:single] to_table = to_table.to_s.pluralize end skr_foreign_keys[ to_table.to_sym ] = options end
skr_state()
click to toggle source
# File lib/skr/db/migration_helpers.rb, line 19 def skr_state column( :state, :integer, null: false, default: 0, limit: 2 ) end
skr_track_modifications( create_only: false )
click to toggle source
track modifications
# File lib/skr/db/migration_helpers.rb, line 24 def skr_track_modifications( create_only: false ) column( :created_at, :datetime, :null=>false ) column( :created_by_id, :integer, :null=>false ) unless create_only column( :updated_at, :datetime, :null=>false ) column( :updated_by_id, :integer, :null=>false ) end end
skr_visible_id()
click to toggle source
# File lib/skr/db/migration_helpers.rb, line 14 def skr_visible_id column( :visible_id, :string, :null=>false ) skr_extra_indexes['visible_id'] = {} end