module AssociateJsonb::ConnectionAdapters::SchemaStatements
Public Instance Methods
add_constraint(table_name, **options)
click to toggle source
# File lib/associate_jsonb/connection_adapters/schema_statements.rb, line 57 def add_constraint(table_name, **options) at = create_alter_table table_name at.add_constraint(**options) execute schema_creation.accept at end
add_jsonb_foreign_key_function()
click to toggle source
# File lib/associate_jsonb/connection_adapters/schema_statements.rb, line 11 def add_jsonb_foreign_key_function execute schema_creation.accept(AddJsonbForeignKeyFunction.new) end
add_jsonb_nested_set_function()
click to toggle source
# File lib/associate_jsonb/connection_adapters/schema_statements.rb, line 7 def add_jsonb_nested_set_function execute schema_creation.accept(AddJsonbNestedSetFunction.new) end
create_table(table_name, **options) { |td| ... }
click to toggle source
# File lib/associate_jsonb/connection_adapters/schema_statements.rb, line 15 def create_table(table_name, **options) td = create_table_definition(table_name, **options) if options[:id] != false && !options[:as] pk = options.fetch(:primary_key) do ActiveRecord::Base.get_primary_key table_name.to_s.singularize end if pk.is_a?(Array) td.primary_keys pk else td.primary_key pk, options.fetch(:id, :primary_key), **options.except(:comment) end end yield td if block_given? if options[:force] drop_table(table_name, **options, if_exists: true) end result = execute schema_creation.accept td td.indexes.each do |column_name, index_options| add_index(table_name, column_name, index_options) end td.constraints.each do |ct| add_constraint(table_name, **ct) end if table_comment = options[:comment].presence change_table_comment(table_name, table_comment) end td.columns.each do |column| change_column_comment(table_name, column.name, column.comment) if column.comment.present? end result end