ce-add-memberships-constraint Add unique index to memberships to avoid duplicate records

The memberships table does not currently have any constraints/indexes to
prevent duplicate entries, e.g. it is theoretically possible to have a
membership record where a user is a member and admin simultaneously, or
two admin/member records;

Before this was applied, we had a small amount of records keeping us
from applying the index. The first part of the migration therefore deletes those
offending records; the second part then creates the index.

Dropping the migration will remove the index.

Curtis Ekstrom avatar Curtis Ekstrom

Push event #1002.1 failed

  • Ran for
AMD64
Ruby: 2.3.4
Git
RAILS_ENV=test
language: ruby
sudo: false

services:
  - postgresql

addons:
  postgresql: "9.6"

cache:
  directories:
    - vendor/bundle

rvm: "2.3.4"

env:
  - RAILS_ENV=test

script:
  - bundle exec rspec spec
  - script/validate_structure_file.rb db/main/structure-original.sql

before_script:
  - cp db/main/structure.sql db/main/structure-original.sql
  - cp config/database.yml.travis config/database.yml
Build Config
{
  "os": [
    "linux"
  ],
  "env": {
    "matrix": [
      "RAILS_ENV=test"
    ]
  },
  "rvm": [
    "2.3.4"
  ],
  "dist": "trusty",
  "sudo": false,
  "cache": {
    "directories": [
      "vendor/bundle"
    ]
  },
  "addons": {
    "postgresql": "9.6"
  },
  "script": [
    "bundle exec rspec spec",
    "script/validate_structure_file.rb db/main/structure-original.sql"
  ],
  "language": "ruby",
  "services": [
    "postgresql"
  ],
  "before_script": [
    "cp db/main/structure.sql db/main/structure-original.sql",
    "cp config/database.yml.travis config/database.yml"
  ]
}