Question

I'm developing an information system in Ruby on Rails.

I want to hand out following uids to users:

0: root
1-499: system services (server-side)
500: system admin
501-999: external apps (apps that connect through API)
1000+: human users

I have the following migration set up:

class SetUsersAutoincrementValue < ActiveRecord::Migration
  def change
    execute("ALTER SEQUENCE users_id_seq RESTART WITH 1000")
  end
end

The migration works as expected. However, it doesn't if triggered by rake db:reset db:migrate.

What to do?

Thanks

Was it helpful?

Solution

I suppose rake db:migrate:reset.

OTHER TIPS

Try to restart the ruby server (Puma) may help.

I run the SQL command ALTER TABLE directly on DB to change a table id column from INT to BIGINT.

After updating, when inserting big number I got an error out of range for ActiveModel::Type::Integer with limit 4"

After restart ruby server, everything works well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top