Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 397
lmojzis Avatar asked Mar 11 '26 10:03

lmojzis


1 Answers

I suppose rake db:migrate:reset.

like image 197
rochefort Avatar answered Mar 13 '26 00:03

rochefort