module Skr::Core::DB::TableFields
Public Instance Methods
skr_code_identifier()
click to toggle source
# File lib/skr/core/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/core/db/migration_helpers.rb, line 31 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/core/db/migration_helpers.rb, line 57 def skr_extra_indexes @skr_extra_indexs ||= {} end
skr_foreign_keys()
click to toggle source
# File lib/skr/core/db/migration_helpers.rb, line 53 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/core/db/migration_helpers.rb, line 39 def skr_reference( to_table, *args ) options = args.extract_options! options[:column] ||= to_table.to_s + '_id' column( options[:column], :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_track_modifications( create_only: false )
click to toggle source
track modifications
# File lib/skr/core/db/migration_helpers.rb, line 22 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/core/db/migration_helpers.rb, line 14 def skr_visible_id column( :visible_id, :integer, :null=>false ) skr_extra_indexes['visible_id'] = { function: 'CAST(visible_id AS VARCHAR)' } end