Rails: ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "booking_number_seq" does not exist

Created on 23 Aug 2018  路  1Comment  路  Source: rails/rails

Steps to reproduce

I have added a auto incremented for one of the column by using snippet and schema.rb doesn't have anything related to creating below sequence.

ruby execute <<-SQL CREATE SEQUENCE booking_number_seq START 15000; ALTER SEQUENCE booking_number_seq OWNED BY bookings.booking_number; ALTER TABLE bookings ALTER COLUMN booking_number SET DEFAULT nextval('booking_number_seq'); SQL

Expected behavior

My schema.rb should able to create complete db structure via bundle exec rake db:schema:load .

Actual behavior

When I am running the schema load, it's breaking and can't able to find the sequence and below is the error.
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "booking_number_seq" does not exist

System configuration

Rails version: 5.2.1

Ruby version: 2.5.1p57

Most helpful comment

db/schema.rb cannot express everything your database may support such as triggers, sequences, stored procedures, check constraints, etc.
If you want to use SEQUENCE, please set the schema format to :sql.
Ref: https://edgeguides.rubyonrails.org/active_record_migrations.html#schema-dumping-and-you

>All comments

db/schema.rb cannot express everything your database may support such as triggers, sequences, stored procedures, check constraints, etc.
If you want to use SEQUENCE, please set the schema format to :sql.
Ref: https://edgeguides.rubyonrails.org/active_record_migrations.html#schema-dumping-and-you

Was this page helpful?
0 / 5 - 0 ratings