added Group model
This commit is contained in:
parent
52791b737b
commit
ce7f896e0c
|
@ -0,0 +1,4 @@
|
||||||
|
class Group < ActiveRecord::Base
|
||||||
|
belongs_to :user
|
||||||
|
has_many :users
|
||||||
|
end
|
|
@ -25,6 +25,8 @@ class User < ActiveRecord::Base
|
||||||
has_many :reports, dependent: :destroy
|
has_many :reports, dependent: :destroy
|
||||||
has_many :moderation_comments, dependent: :destroy
|
has_many :moderation_comments, dependent: :destroy
|
||||||
has_many :moderation_votes, dependent: :destroy
|
has_many :moderation_votes, dependent: :destroy
|
||||||
|
has_many :groups, dependent: :destroy
|
||||||
|
belongs_to :group, foreign_key: :target_id
|
||||||
|
|
||||||
SCREEN_NAME_REGEX = /\A[a-zA-Z0-9_]{1,16}\z/
|
SCREEN_NAME_REGEX = /\A[a-zA-Z0-9_]{1,16}\z/
|
||||||
WEBSITE_REGEX = /https?:\/\/([A-Za-z.\-]+)\/?(?:.*)/i
|
WEBSITE_REGEX = /https?:\/\/([A-Za-z.\-]+)\/?(?:.*)/i
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
class CreateGroups < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :groups do |t|
|
||||||
|
t.integer :user_id, null: false
|
||||||
|
t.integer :target_id, null: false
|
||||||
|
t.string :name
|
||||||
|
t.string :display_name
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index :groups, :user_id
|
||||||
|
add_index :groups, :target_id
|
||||||
|
add_index :groups, :name
|
||||||
|
add_index :groups, [:user_id, :name], unique: true
|
||||||
|
end
|
||||||
|
end
|
16
db/schema.rb
16
db/schema.rb
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20150103200732) do
|
ActiveRecord::Schema.define(version: 20150108121010) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -38,6 +38,20 @@ ActiveRecord::Schema.define(version: 20150103200732) do
|
||||||
|
|
||||||
add_index "comments", ["user_id", "created_at"], name: "index_comments_on_user_id_and_created_at", using: :btree
|
add_index "comments", ["user_id", "created_at"], name: "index_comments_on_user_id_and_created_at", using: :btree
|
||||||
|
|
||||||
|
create_table "groups", force: true do |t|
|
||||||
|
t.integer "user_id", null: false
|
||||||
|
t.integer "target_id", null: false
|
||||||
|
t.string "name"
|
||||||
|
t.string "display_name"
|
||||||
|
t.datetime "created_at"
|
||||||
|
t.datetime "updated_at"
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index "groups", ["name"], name: "index_groups_on_name", using: :btree
|
||||||
|
add_index "groups", ["target_id"], name: "index_groups_on_target_id", using: :btree
|
||||||
|
add_index "groups", ["user_id", "name"], name: "index_groups_on_user_id_and_name", unique: true, using: :btree
|
||||||
|
add_index "groups", ["user_id"], name: "index_groups_on_user_id", using: :btree
|
||||||
|
|
||||||
create_table "inboxes", force: true do |t|
|
create_table "inboxes", force: true do |t|
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
t.integer "question_id"
|
t.integer "question_id"
|
||||||
|
|
Loading…
Reference in New Issue