Reference documentation and code samples for the activerecord-spanner-adapter module ActiveRecord::ConnectionAdapters::Spanner::SchemaStatements.
SchemaStatements
Collection of methods to handle database schema.
Methods
#_add_foreign_key
def _add_foreign_key(from_table, to_table, **options)
#_remove_columns
def _remove_columns(table_name, *column_names)
#add_belongs_to
def add_belongs_to(table_name, ref_name, **options)
Reference Column
#add_column
def add_column(table_name, column_name, type, **options)
#add_foreign_key
def add_foreign_key(from_table, to_table, **options)
#add_index
def add_index(table_name, column_name, options = {})
#add_reference
def add_reference(table_name, ref_name, **options)
Reference Column
#assume_migrated_upto_version
def assume_migrated_upto_version(version)
#change_column
def change_column(table_name, column_name, type, **options)
#change_column_default
def change_column_default(_table_name, _column_name, _default_or_changes)
#change_column_null
def change_column_null(table_name, column_name, null, _default = nil)
#check_constraints
def check_constraints(table_name)
Check Contraints
#column_definitions
def column_definitions(table_name)
Column
#create_join_table
def create_join_table(table_1, table_2, column_options: {}, **options)
Creates a join table that uses all the columns in the table as the primary key by default, unless an explicit primary key has been defined for the table. ActiveRecord will by default generate join tables without a primary key. Cloud Spanner however requires all tables to have a primary key. Instead of adding an additional column to the table only for the purpose of being the primary key, the Spanner ActiveRecord adapter defines a primary key that contains all the columns in the join table, as all values in the table should be unique anyways.
#create_schema_dumper
def create_schema_dumper(options)
#create_table
def create_table(table_name, id: :primary_key, **options)
- (td)
#current_database
def current_database()
#data_source_exists?
def data_source_exists?(table_name) -> Boolean
- (Boolean)
#data_sources
def data_sources()
Table
#drop_table
def drop_table(table_name, options = {})
#extract_schema_qualified_name
def extract_schema_qualified_name(string)
#fetch_type_metadata
def fetch_type_metadata(sql_type, ordinal_position = nil, allow_commit_timestamp = nil, generated = nil)
#foreign_keys
def foreign_keys(table_name, column: nil)
Foreign Keys
- (ArgumentError)
#index_name_exists?
def index_name_exists?(table_name, index_name) -> Boolean
- (Boolean)
#indexes
def indexes(table_name)
Index
#insert_versions_sql
def insert_versions_sql(versions)
#migration_context
def migration_context()
#new_column_from_field
def new_column_from_field(_table_name, field, _definitions = nil)
#primary_and_parent_keys
def primary_and_parent_keys(table_name)
#primary_keys
def primary_keys(table_name)
Primary Keys
#quoted_scope
def quoted_scope(name = nil, type: nil)
#remove_column
def remove_column(table_name, column_name, _type = nil, _options = {})
#remove_columns
def remove_columns(table_name, *column_names, _type: nil, **_options)
#remove_foreign_key
def remove_foreign_key(from_table, to_table = nil, **options)
#remove_index
def remove_index(table_name, column_name = nil, **options)
#rename_column
def rename_column(table_name, column_name, new_column_name)
#rename_index
def rename_index(table_name, old_name, new_name)
#rename_table
def rename_table(_table_name, _new_name)
#schema_migration
def schema_migration()
#table_exists?
def table_exists?(table_name) -> Boolean
- (Boolean)
#tables
def tables()
Table
#type_to_sql
def type_to_sql(type, limit: nil, precision: nil, scale: nil, **opts)
rubocop:disable Lint/UnusedMethodArgument
Constants
VERSION_6_1_0
value: Gem::Version.create "6.1.0"
VERSION_6_0_3
value: Gem::Version.create "6.0.3"
VERSION_7_2
value: Gem::Version.create "7.2.0"