Module: ActiveRecord::ConnectionAdapters::SchemaStatements
- Defined in:
- lib/active_record/connection_adapters/ibm_db_pstmt.rb,
lib/active_record/connection_adapters/ibm_db_adapter.rb
Instance Method Summary collapse
- #assume_migrated_upto_version(version) ⇒ Object
- #create_table_definition(*args, **options) ⇒ Object
- #drop_table(table_name, options = {}) ⇒ Object
-
#internal_string_options_for_primary_key ⇒ Object
:nodoc:.
- #unique_constraint_name(table_name, **options) ⇒ Object
-
#valid_column_definition_options ⇒ Object
:nodoc:.
-
#valid_primary_key_options ⇒ Object
:nodoc:.
Instance Method Details
#assume_migrated_upto_version(version) ⇒ Object
1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 |
# File 'lib/active_record/connection_adapters/ibm_db_pstmt.rb', line 1931 def assume_migrated_upto_version(version) version = version.to_i sm_table = quote_table_name(ActiveRecord::Migrator.schema_migrations_table_name) migrated = select_values("SELECT version FROM #{sm_table}").map(&:to_i) versions = Dir['db/migrate/[0-9]*_*.rb'].map do |filename| filename.split('/').last.split('_').first.to_i end unless migrated.include?(version) pstmt = prepare("INSERT INTO #{sm_table} (version) VALUES (?)") execute_prepared_stmt(pstmt, [version]) end inserted = Set.new (versions - migrated).each do |v| if inserted.include?(v) raise "Duplicate migration #{v}. Please renumber your migrations to resolve the conflict." elsif v < version pstmt = prepare("INSERT INTO #{sm_table} (version) VALUES (?)") execute_prepared_stmt(pstmt, [v]) inserted << v end end end |
#create_table_definition(*args, **options) ⇒ Object
571 572 573 574 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 571 def create_table_definition(*args, **) puts_log 'create_table_definition SchemaStatements' TableDefinition.new(self, *args, **) end |
#drop_table(table_name, options = {}) ⇒ Object
563 564 565 566 567 568 569 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 563 def drop_table(table_name, = {}) if [:if_exists] execute("DROP TABLE IF EXISTS #{quote_table_name(table_name)}") else execute("DROP TABLE #{quote_table_name(table_name)}", ) end end |
#internal_string_options_for_primary_key ⇒ Object
:nodoc:
551 552 553 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 551 def # :nodoc: { primary_key: true, null: false } end |
#unique_constraint_name(table_name, **options) ⇒ Object
576 577 578 579 580 581 582 583 584 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 576 def unique_constraint_name(table_name, **) .fetch(:name) do column_or_index = Array([:column] || [:using_index]).map(&:to_s) identifier = "#{table_name}_#{column_or_index * '_and_'}_unique" hashed_identifier = Digest::SHA256.hexdigest(identifier).first(10) "uniq_rails_#{hashed_identifier}" end end |
#valid_column_definition_options ⇒ Object
:nodoc:
559 560 561 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 559 def # :nodoc: ColumnDefinition::OPTION_NAMES + [:auto_increment] end |
#valid_primary_key_options ⇒ Object
:nodoc:
555 556 557 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 555 def # :nodoc: [:limit, :default, :precision, :auto_increment] end |