rpitv / glimpse

Monorepo for the RPI TV Glimpse project
MIT License
3 stars 1 forks source link

Bug: CLI group creation does not auto-increment ID #2

Open robere2 opened 1 year ago

robere2 commented 1 year ago

In the CLI, the ID is manually set when creating groups, which causes PostgreSQL to not increment the auto-increment value for the ID column. When a user tries to insert another group, it will always fail, since the auto-increment value is still set to 1 however a group with ID 1 already exists ("Guest").

There are two possible solutions to this:

  1. Do not insert the ID manually, and then assert that the IDs are correct at the end of the insert(s).
  2. Insert the IDs manually and then manually update the auto-increment value afterwards.

Technically, the ID of the groups shouldn't matter, but in my opinion, we should assert that the default groups are IDs 1-3 just in case.

robere2 commented 1 year ago

auto-increment value can be updated via:

SELECT setval('groups_id_seq', (SELECT MAX(id) FROM groups) + 1, false);

This can also be done manually until this issue is fixed.