mirror of
https://github.com/manyfold3d/manyfold.git
synced 2026-10-22 19:52:18 -05:00
Create admin user on app start, not in data migration
This commit is contained in:
2 files changed
+11
-15
No files matched your search
@@ -21,5 +21,16 @@ module VanDam
|
||||
|
||||
# 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
|
||||
@@ -1,15 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class CreateDefaultAdminUser < ActiveRecord::Migration[7.0]
|
||||
def up
|
||||
User.create(
|
||||
username: "admin",
|
||||
email: "nobody@example.com",
|
||||
admin: true
|
||||
)
|
||||
end
|
||||
|
||||
def down
|
||||
User.find_by(username: "admin").destroy
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user