Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Work with UUID ID column... #915

Open
usiegj00 opened this issue Aug 27, 2020 · 0 comments
Open

Feature Request: Work with UUID ID column... #915

usiegj00 opened this issue Aug 27, 2020 · 0 comments

Comments

@usiegj00
Copy link

Expected behavior

When using UUID type for database table id columns, the behavior should be the same as using integer type for id columns. Note that as of 2020-08-26, to use CMS required ActiveStorage, but ActiveStorage does not handle UUIDs with the default migration, so ActiveStorage's migration must be edited (to allow polymorphic entity associations with UUID columns).

Actual behavior

Instead, CMS gives this error when page#create is attempted:

PG::UndefinedFunction: ERROR: operator does not exist: uuid = integer LINE 1: ...s_categorizations" ON "comfy_cms_categories"."id" = "comfy_c... ^ HINT: No operator matches the given name and argument types. You might need to add explicit type casts.```

### Steps to reproduce
Recreate with new Rails app but use UUID for ID column:

$ rails new cms-test

Add Postgres gem and use postgres.

$ cat > config/initializers/generators.rb
Rails.application.config.generators do |g|
  g.orm :active_record, primary_key_type: :uuid
end
$ rails webpacker:install
$ rails active_storage:install

We use UUIDs, so ActiveStorage requires polymorphic ids to be UUIDs:

$ diff db/migrate/create_active_storage… default
4c4
<     create_table :active_storage_blobs do |t|

     create_table :active_storage_blobs, id: :uuid do |t|
16c16
<     create_table :active_storage_attachments do |t|


     create_table :active_storage_attachments, id: :uuid do |t|
18,19c18,19
<       t.references :record,   null: false, polymorphic: true, index: false
<       t.references :blob,     null: false


       t.references :record,   null: false, polymorphic: true, index: false, type: :uuid
       t.references :blob,     null: false, type: :uuid

Same for CMS:

gem "comfortable_mexican_sofa", "~> 2.0.0"
bundle install
rails generate comfy:cms

Update the CMS migration to use UUIDs (see attached).

20200827044850_create_active_storage_tables.active_storage.rb.txt
20200827045455_create_cms.rb.txt

rake db:migrate

Create a site and see a URL like (it works):

http://localhost:3001/admin/sites/95eb4f68-5115-45e3-917b-1aa5bcfa7ffc/layouts/new

Create a layout (it works).

But Page->Create gives the above error.


### System configuration
**Rails version**:

gem 'rails', '~> 6.0.2', '>= 6.0.2.2'


**CMS version**:

gem "comfortable_mexican_sofa", "~> 2.0.0"


**Ruby version**:

ruby '2.6.3'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant