Adding db seed, fixing migration issues
This commit is contained in:
parent
73833dd2bf
commit
92c3a6d2be
|
@ -13,9 +13,5 @@ To use:
|
||||||
* Copy config/config.yml.example to config/config.yml and edit appropriately
|
* Copy config/config.yml.example to config/config.yml and edit appropriately
|
||||||
* Copy config/database.yml.example to config/database.yml and edit appropriately
|
* Copy config/database.yml.example to config/database.yml and edit appropriately
|
||||||
* Copy config/initializers/secret_token.rb.example to config/config/initializers/secret_token.rb and edit appropriately
|
* Copy config/initializers/secret_token.rb.example to config/config/initializers/secret_token.rb and edit appropriately
|
||||||
* Run bundle install, rake db:migrate, etc.
|
* See/edit db/seeds.rb for the initial admin account info.
|
||||||
* Use the Rails console to create a new User with admin rights
|
* Run bundle install, rake db:migrate, rake db:seed, etc.
|
||||||
* user = User.new
|
|
||||||
* user.password = "foobar"
|
|
||||||
* user.admin = true
|
|
||||||
* user.save
|
|
|
@ -1,5 +1,9 @@
|
||||||
class ChangeUsersMemberToInteger < ActiveRecord::Migration
|
class ChangeUsersMemberToInteger < ActiveRecord::Migration
|
||||||
def change
|
def up
|
||||||
change_column :users, :member, :integer
|
execute 'ALTER TABLE users ALTER COLUMN member TYPE integer USING (member::integer)'
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
execute 'ALTER TABLE users ALTER COLUMN member TYPE text USING (member::text)'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
class ChangeMemberLevelToInteger < ActiveRecord::Migration
|
class ChangeMemberLevelToInteger < ActiveRecord::Migration
|
||||||
def up
|
def up
|
||||||
change_column :users, :member_level, :integer
|
execute 'ALTER TABLE users ALTER COLUMN member_level TYPE integer USING (member_level::integer)'
|
||||||
end
|
end
|
||||||
|
|
||||||
def down
|
def down
|
||||||
change_column :users, :member_level, :string
|
execute 'ALTER TABLE users ALTER COLUMN member_level TYPE text USING (member_level::text)'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
6
db/seeds.rb
Normal file
6
db/seeds.rb
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
User.create({
|
||||||
|
name: "Admin",
|
||||||
|
email: "admin@example.com",
|
||||||
|
password: "password",
|
||||||
|
admin: true
|
||||||
|
})
|
Loading…
Reference in New Issue
Block a user