Skip to content

Commit

Permalink
Merge pull request #1329 from Floppy/fix-admin-user
Browse files Browse the repository at this point in the history
Create admin user on application boot, not at migration time
  • Loading branch information
Floppy committed Jul 6, 2023
2 parents 714b3ad + edafd8a commit 80b6444
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
11 changes: 11 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,16 @@ class Application < Rails::Application

# Don't generate system test files.
config.generators.system_tests = nil

config.after_initialize do
# Create default admin user if there aren't any users yet
if ActiveRecord::Base.connection.table_exists?("users") && User.count == 0
User.create(
username: "admin",
email: "nobody@example.com",
admin: true
)
end
end
end
end
15 changes: 0 additions & 15 deletions db/data/20220614214418_create_default_admin_user.rb

This file was deleted.

2 changes: 0 additions & 2 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 80b6444

Please sign in to comment.