Search code examples
ruby-on-railsrubypostgresqldatabase-migrationuser-management

ALTER SEQUENCE on rake db:reset db:migrate not working


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


Solution

  • I suppose rake db:migrate:reset.