0

I tried to learn new stuff and use Ahoy gem for my private project. While doing research online, I encountered one repo with Rails 4.2 and Ahoy 1.6 and one thing struck me. Then I started googling and it seems like it's not a single repo issue only.

class CreateVisits < ActiveRecord::Migration
  def change
    create_table :visits, id: false do |t|
      t.uuid :id, default: nil, primary_key: true
(...)

rest of code omitted for readability

Am I missing something, or are those mutually exclusive lines? (not to mention primary key being nil by default?)

I ran almost the same migration locally (without Ahoy gem, with changed table name), and I got nicely-looking db/schema.rb (at first glance - no errors yet), but of course when I try create new object, I hit ActiveRecord::NotNullViolation: PG::NotNullViolation: ERROR: null value in column "id" violates not-null constraint error

In my opinion, I'd have write something like this to make it work, or am I missing something really important here that blocks me from persisting an object in DB?

class CreateVisits < ActiveRecord::Migration
  def change
    create_table :visits do |t|
      t.uuid :id, primary_key: true
(...)
Rigi
  • 2,870
  • 1
  • 9
  • 18

1 Answers1

0

Seems like this thing was not related to this Gem, but to other Dev running migration outside Rails migrations and not letting anyone know. This created some confusion between environments.

Rigi
  • 2,870
  • 1
  • 9
  • 18