method
set_pk_sequence!
v6.1.7.7 -
Show latest stable
- Class:
ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaStatements
set_pk_sequence!(table, value)public
Sets the sequence of a table’s primary key to the specified value.
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb, line 260
def set_pk_sequence!(table, value) #:nodoc:
pk, sequence = pk_and_sequence_for(table)
if pk
if sequence
quoted_sequence = quote_table_name(sequence)
query_value("SELECT setval(#{quote(quoted_sequence)}, #{value})", "SCHEMA")
else
@logger.warn "#{table} has primary key #{pk} with no default sequence." if @logger
end
end
end Related methods
- Instance methods
- ON
- add_column
- add_column_for_alter
- add_index
- add_index_opclass
- add_options_for_index_columns
- change_column
- change_column_comment
- change_column_default
- change_column_default_for_alter
- change_column_for_alter
- change_column_null
- change_column_null_for_alter
- change_table_comment
- check_constraints
- client_min_messages
- client_min_messages=
- collation
- columns_for_distinct
- create_alter_table
- create_database
- create_schema
- create_schema_dumper
- create_table_definition
- ctype
- current_database
- current_schema
- data_source_sql
- default_sequence_name
- drop_database
- drop_schema
- drop_table
- encoding
- extract_foreign_key_action
- extract_schema_qualified_name
- fetch_type_metadata
- foreign_keys
- foreign_table_exists?
- foreign_tables
- index_name_exists?
- indexes
- new_column_from_field
- pk_and_sequence_for
- primary_keys
- quoted_scope
- recreate_database
- remove_index
- rename_column
- rename_index
- rename_table
- reset_pk_sequence!
- schema_creation
- schema_exists?
- schema_names
- schema_search_path
- schema_search_path=
- sequence_name_from_parts
- serial_sequence
- set_pk_sequence!
- table_comment
- table_options
- type_to_sql
- update_table_definition
- validate_check_constraint
- validate_constraint
- validate_foreign_key