# circleCI test failing on postgres auto-increment column

**URL:** <https://discuss.circleci.com/t/circleci-test-failing-on-postgres-auto-increment-column/34791>\
**Category:** Databases\
**Created:** [March 4, 2020, 6:00pm UTC](https://discuss.circleci.com/t/circleci-test-failing-on-postgres-auto-increment-column/34791 "2020-03-04T18:00:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yaboiwaffles](https://avatars.discourse-cdn.com/v4/letter/y/22d042/32.png) [@yaboiwaffles](https://discuss.circleci.com/u/yaboiwaffles)\
**Post date:** [March 4, 2020, 6:00pm UTC](https://discuss.circleci.com/t/circleci-test-failing-on-postgres-auto-increment-column/34791/1 "2020-03-04T18:00:28Z")

</div>

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

```auto
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

```auto
  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

```auto
    t.integer "hyperlocal_destination_id", default: -> { "nextval('hyperlocal_destination_id_seq'::regclass)" }

```

And this is what the config.yml looks like

```auto
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!

---

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [March 6, 2020, 4:20pm UTC](https://discuss.circleci.com/t/circleci-test-failing-on-postgres-auto-increment-column/34791/2 "2020-03-06T16:20:18Z")

</div>

It looks like there is a discrepancy between your migration and your result. You have a `ALTER TABLE place_destinations` in your migration, but it is reporting a `CREATE TABLE "place_destinations"` in the error.

Also you are talking about PostgreSQL tables, but this query is being run in SQLite.
