So I am having a hard time figuring out how to fix a failing test right now. I recently made a new branch on my project where I wrote a ruby migration that sets a column in one of my postgres tables to auto-increment. I’ve run my tests locally and everything is working fine. When I pushed my code though the circleCI tests fail and I keep getting this particular error
rails aborted!
ActiveRecord::StatementInvalid: SQLite3::SQLException: near "(": syntax error: CREATE TABLE "place_destinations" ("id" serial NOT NULL PRIMARY KEY, "place_id" integer, "destination_id" integer, "hyperlocal_destination_id" integer DEFAULT nextval('hyperlocal_destination_id_seq'::regclass))
this is the migration
def up
execute <<-SQL
CREATE SEQUENCE hyperlocal_destination_id_seq START 1;
ALTER SEQUENCE hyperlocal_destination_id_seq OWNED BY place_destinations.hyperlocal_destination_id;
ALTER TABLE place_destinations ALTER COLUMN hyperlocal_destination_id SET DEFAULT nextval('hyperlocal_destination_id_seq');
SQL
end
My schema.rb for this column looks like this and was generated by the rails
t.integer "hyperlocal_destination_id", default: -> { "nextval('hyperlocal_destination_id_seq'::regclass)" }
And this is what the config.yml looks like
version: 2
jobs:
build:
docker:
# Find other images @ https://circleci.com/docs/2.0/circleci-images/
- image: circleci/ruby:2.6.2-node
environment:
RAILS_ENV: test
PGHOST: 127.0.0.1
PGUSER: root
- image: circleci/postgres:9.6.2-alpine
environment:
POSTGRES_USER: root
POSTGRES_DB: circle-test_test
working_directory: ~/repo
steps:
- checkout
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "Gemfile.lock" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run:
name: install dependencies
command: |
bundle install --jobs=4 --retry=3 --path vendor/bundle
- save_cache:
paths:
- ./vendor/bundle
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
# Database setup
- run: bundle exec rake db:create
- run: bundle exec rake db:schema:load
# run tests!
- run:
command: bundle exec rake test
when: always
# collect reports
- store_test_results:
path: test/reports
- store_artifacts:
path: /tmp/test-results
destination: test-results
any help would be appreciated!