summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorjomo <github@jomo.tv>2013-10-07 04:59:21 +0200
committerjomo <github@jomo.tv>2013-10-07 04:59:21 +0200
commit5fac505a31e6fdaf108ac29cf927ec097c925632 (patch)
treecc6b2c838e85dc4b3b34a1c5504b89a20f1027d7 /db
parent27613877038bb37488e1f71902071b82c655b304 (diff)
another big commit :D
Diffstat (limited to 'db')
-rw-r--r--db/migrate/00000000000001_create_roles.rb11
-rw-r--r--db/migrate/00000000000002_create_users.rb23
-rw-r--r--db/migrate/00000000000003_create_blogposts.rb (renamed from db/migrate/20130526015928_create_blogposts.rb)8
-rw-r--r--db/migrate/00000000000004_create_comments.rb (renamed from db/migrate/20130526020734_create_comments.rb)6
-rw-r--r--db/migrate/00000000000005_create_forumgroups.rb10
-rw-r--r--db/migrate/00000000000006_create_forums.rb (renamed from db/migrate/20130802051521_create_forums.rb)9
-rw-r--r--db/migrate/00000000000007_create_forumthreads.rb17
-rw-r--r--db/migrate/20130518221216_create_users.rb20
-rw-r--r--db/migrate/20130727063752_add_youtube_to_users.rb5
-rw-r--r--db/migrate/20130727071804_add_youtube_channelname.rb8
-rw-r--r--db/migrate/20130728003021_add_twitter_to_users.rb5
-rw-r--r--db/migrate/20130802051129_add_forumgroups.rb9
-rw-r--r--db/migrate/20130922181339_add_sessions_table.rb12
-rw-r--r--db/schema.rb78
-rw-r--r--db/seeds.rb40
15 files changed, 175 insertions, 86 deletions
diff --git a/db/migrate/00000000000001_create_roles.rb b/db/migrate/00000000000001_create_roles.rb
new file mode 100644
index 0000000..8fb2b08
--- /dev/null
+++ b/db/migrate/00000000000001_create_roles.rb
@@ -0,0 +1,11 @@
+class CreateRoles < ActiveRecord::Migration
+ def up
+ create_table :roles do |t|
+ t.string :name
+ t.integer :value
+ end
+ end
+
+ def down
+ end
+end
diff --git a/db/migrate/00000000000002_create_users.rb b/db/migrate/00000000000002_create_users.rb
new file mode 100644
index 0000000..1da43af
--- /dev/null
+++ b/db/migrate/00000000000002_create_users.rb
@@ -0,0 +1,23 @@
+class CreateUsers < ActiveRecord::Migration
+ def change
+ create_table :users do |t|
+ t.string :name, :unique => true, :null => false
+ t.string :password_digest, :null => false
+ t.string :ign, :unique => true, :null => false
+ t.string :email, :unique => true, :null => false
+ t.string :confirm_code, :null => false
+ t.text :about
+ t.string :last_ip
+ t.string :skype, :unique => true
+ t.boolean :skype_public, :default => false
+ t.string :youtube, :unique => true
+ t.string :youtube_channelname
+ t.string :twitter, :unique => true
+ t.datetime :last_login
+
+ t.references :role, :null => false
+
+ t.timestamps
+ end
+ end
+end \ No newline at end of file
diff --git a/db/migrate/20130526015928_create_blogposts.rb b/db/migrate/00000000000003_create_blogposts.rb
index 2c910a6..b8d5c7e 100644
--- a/db/migrate/20130526015928_create_blogposts.rb
+++ b/db/migrate/00000000000003_create_blogposts.rb
@@ -2,10 +2,12 @@ class CreateBlogposts < ActiveRecord::Migration
def change
create_table :blogposts do |t|
t.string :title
- t.text :text
- t.references :user
+ t.text :content
+
+ t.references :user_author
+ t.references :user_editor
t.timestamps
end
end
-end
+end \ No newline at end of file
diff --git a/db/migrate/20130526020734_create_comments.rb b/db/migrate/00000000000004_create_comments.rb
index 482e866..70a2988 100644
--- a/db/migrate/20130526020734_create_comments.rb
+++ b/db/migrate/00000000000004_create_comments.rb
@@ -1,8 +1,10 @@
class CreateComments < ActiveRecord::Migration
def change
create_table :comments do |t|
- t.text :text
- t.integer :user_id
+ t.text :content
+
+ t.references :user_author
+ t.references :user_editor
t.references :blogpost
t.timestamps
diff --git a/db/migrate/00000000000005_create_forumgroups.rb b/db/migrate/00000000000005_create_forumgroups.rb
new file mode 100644
index 0000000..942ad26
--- /dev/null
+++ b/db/migrate/00000000000005_create_forumgroups.rb
@@ -0,0 +1,10 @@
+class CreateForumgroups < ActiveRecord::Migration
+ def change
+ create_table :forumgroups do |t|
+ t.string :name
+ t.integer :position
+ t.integer :read_permission
+ t.integer :write_permission
+ end
+ end
+end \ No newline at end of file
diff --git a/db/migrate/20130802051521_create_forums.rb b/db/migrate/00000000000006_create_forums.rb
index d7017ad..77b5439 100644
--- a/db/migrate/20130802051521_create_forums.rb
+++ b/db/migrate/00000000000006_create_forums.rb
@@ -1,11 +1,12 @@
class CreateForums < ActiveRecord::Migration
def change
create_table :forums do |t|
- t.string "name"
- t.integer "position"
- t.references :forumgroup
+ t.string :name
+ t.integer :position
+ t.integer :read_permission
+ t.integer :write_permission
- t.timestamps
+ t.references :forumgroup
end
end
end
diff --git a/db/migrate/00000000000007_create_forumthreads.rb b/db/migrate/00000000000007_create_forumthreads.rb
new file mode 100644
index 0000000..1f06761
--- /dev/null
+++ b/db/migrate/00000000000007_create_forumthreads.rb
@@ -0,0 +1,17 @@
+class CreateForumthreads < ActiveRecord::Migration
+ def change
+ create_table :forumthreads do |t|
+ t.string :title
+ t.text :content
+ t.boolean :sticky, :default => false
+ t.boolean :locked, :default => false
+
+ t.references :user_author
+ t.references :user_editor
+
+ t.references :forum
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20130518221216_create_users.rb b/db/migrate/20130518221216_create_users.rb
deleted file mode 100644
index 0056a11..0000000
--- a/db/migrate/20130518221216_create_users.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-class CreateUsers < ActiveRecord::Migration
- def change
- create_table :users do |t|
- t.string :name, :unique => true, :null => false
- t.string :ign, :unique => true, :null => false
- t.integer :rank, :default => 10, :null => false
- t.boolean :banned, :default => false
- t.string :email, :unique => true, :null => false
- t.text :about
- t.string :password_digest, :null => false
- t.string :last_ip
- t.string :skype
- t.boolean :skype_public, :default => false
- t.datetime :last_login
- t.datetime :last_active
-
- t.timestamps
- end
- end
-end
diff --git a/db/migrate/20130727063752_add_youtube_to_users.rb b/db/migrate/20130727063752_add_youtube_to_users.rb
deleted file mode 100644
index 1ff74c9..0000000
--- a/db/migrate/20130727063752_add_youtube_to_users.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class AddYoutubeToUsers < ActiveRecord::Migration
- def change
- add_column :users, :youtube, :string
- end
-end
diff --git a/db/migrate/20130727071804_add_youtube_channelname.rb b/db/migrate/20130727071804_add_youtube_channelname.rb
deleted file mode 100644
index 4157ddb..0000000
--- a/db/migrate/20130727071804_add_youtube_channelname.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-class AddYoutubeChannelname < ActiveRecord::Migration
- def up
- add_column :users, :youtube_channelname, :string
- end
-
- def down
- end
-end
diff --git a/db/migrate/20130728003021_add_twitter_to_users.rb b/db/migrate/20130728003021_add_twitter_to_users.rb
deleted file mode 100644
index e6b9f86..0000000
--- a/db/migrate/20130728003021_add_twitter_to_users.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class AddTwitterToUsers < ActiveRecord::Migration
- def change
- add_column :users, :twitter, :string
- end
-end
diff --git a/db/migrate/20130802051129_add_forumgroups.rb b/db/migrate/20130802051129_add_forumgroups.rb
deleted file mode 100644
index 565f5b0..0000000
--- a/db/migrate/20130802051129_add_forumgroups.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-class AddForumgroups < ActiveRecord::Migration
- def change
- create_table :forumgroups do |t|
- t.string :name
- t.integer :position
- t.timestamps
- end
- end
-end \ No newline at end of file
diff --git a/db/migrate/20130922181339_add_sessions_table.rb b/db/migrate/20130922181339_add_sessions_table.rb
new file mode 100644
index 0000000..4c87956
--- /dev/null
+++ b/db/migrate/20130922181339_add_sessions_table.rb
@@ -0,0 +1,12 @@
+class AddSessionsTable < ActiveRecord::Migration
+ def change
+ create_table :sessions do |t|
+ t.string :session_id, :null => false
+ t.text :data
+ t.timestamps
+ end
+
+ add_index :sessions, :session_id
+ add_index :sessions, :updated_at
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 26ec139..bdcd2e5 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,57 +11,85 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20130802051521) do
+ActiveRecord::Schema.define(:version => 20130922181339) do
create_table "blogposts", :force => true do |t|
t.string "title"
- t.text "text"
- t.integer "user_id"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
+ t.text "content"
+ t.integer "user_author_id"
+ t.integer "user_editor_id"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
end
create_table "comments", :force => true do |t|
- t.text "text"
- t.integer "user_id"
+ t.text "content"
+ t.integer "user_author_id"
+ t.integer "user_editor_id"
t.integer "blogpost_id"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
end
create_table "forumgroups", :force => true do |t|
- t.string "name"
- t.integer "position"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
+ t.string "name"
+ t.integer "position"
+ t.integer "read_permission"
+ t.integer "write_permission"
end
create_table "forums", :force => true do |t|
- t.string "name"
- t.integer "position"
- t.integer "forumgroup_id"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
+ t.string "name"
+ t.integer "position"
+ t.integer "read_permission"
+ t.integer "write_permission"
+ t.integer "forumgroup_id"
+ end
+
+ create_table "forumthreads", :force => true do |t|
+ t.string "title"
+ t.text "content"
+ t.boolean "sticky", :default => false
+ t.boolean "locked", :default => false
+ t.integer "user_author_id"
+ t.integer "user_editor_id"
+ t.integer "forum_id"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
+ create_table "roles", :force => true do |t|
+ t.string "name"
+ t.integer "value"
+ end
+
+ create_table "sessions", :force => true do |t|
+ t.string "session_id", :null => false
+ t.text "data"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
end
+ add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id"
+ add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at"
+
create_table "users", :force => true do |t|
t.string "name", :null => false
+ t.string "password_digest", :null => false
t.string "ign", :null => false
- t.integer "rank", :default => 10, :null => false
- t.boolean "banned", :default => false
t.string "email", :null => false
+ t.string "confirm_code", :null => false
t.text "about"
- t.string "password_digest", :null => false
t.string "last_ip"
t.string "skype"
t.boolean "skype_public", :default => false
- t.datetime "last_login"
- t.datetime "last_active"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
t.string "youtube"
t.string "youtube_channelname"
t.string "twitter"
+ t.datetime "last_login"
+ t.integer "role_id", :null => false
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
end
end
diff --git a/db/seeds.rb b/db/seeds.rb
index 3b8c43a..b8e7941 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -1,12 +1,42 @@
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
-#
-User.create(
+
+Role.create!([
+ {name: "disabled", value: 1},
+ {name: "banned", value: 2},
+ {name: "unconfirmed", value: 5},
+ {name: "default", value: 10},
+ {name: "donor", value: 40},
+ {name: "mod", value: 100},
+ {name: "admin", value: 200},
+ {name: "superadmin", value: 500}
+])
+
+userpw = SecureRandom.hex(64)
+
+deleted_user = User.create!(
+ name: "Deleted user",
+ email: "redstonerserver@gmail.com",
+ ign: "Mojang",
+ about: "Hey, apparently, I do no longer exist. This is just a placeholder profile",
+ password: userpw,
+ password_confirmation: userpw,
+ role: Role.get(:disabled),
+ confirm_code: SecureRandom.hex(16),
+ skype: "echo123",
+ skype_public: true,
+ last_ip: "0.0.0.0",
+ last_login: Time.utc(0).to_datetime
+ )
+ deleted_user.update_attribute(:ign, "Steve")
+
+User.create!(
name: "Redstone Sheep",
ign: "noobkackboon",
email: "theredstonesheep@gmail.com",
about: "Hi, I am the admin :)",
- password: "123",
- password_confirmation: "123",
- rank: 500
+ password: "123456789",
+ password_confirmation: "123456789",
+ role: Role.get(:superadmin),
+ confirm_code: SecureRandom.hex(16)
) \ No newline at end of file