Adding db seed, fixing migration issues

This commit is contained in:
Will Bradley 2014-02-08 19:13:45 -07:00
parent 73833dd2bf
commit 92c3a6d2be
4 changed files with 16 additions and 10 deletions

View File

@ -13,9 +13,5 @@ To use:
* 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/initializers/secret_token.rb.example to config/config/initializers/secret_token.rb and edit appropriately
* Run bundle install, rake db:migrate, etc.
* Use the Rails console to create a new User with admin rights
* user = User.new
* user.password = "foobar"
* user.admin = true
* user.save
* See/edit db/seeds.rb for the initial admin account info.
* Run bundle install, rake db:migrate, rake db:seed, etc.

View File

@ -1,5 +1,9 @@
class ChangeUsersMemberToInteger < ActiveRecord::Migration
def change
change_column :users, :member, :integer
def up
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

View File

@ -1,9 +1,9 @@
class ChangeMemberLevelToInteger < ActiveRecord::Migration
def up
change_column :users, :member_level, :integer
execute 'ALTER TABLE users ALTER COLUMN member_level TYPE integer USING (member_level::integer)'
end
def down
change_column :users, :member_level, :string
execute 'ALTER TABLE users ALTER COLUMN member_level TYPE text USING (member_level::text)'
end
end

6
db/seeds.rb Normal file
View File

@ -0,0 +1,6 @@
User.create({
name: "Admin",
email: "admin@example.com",
password: "password",
admin: true
})