From b4f528efbdefb09a41f6b153802d3ef6de8b7614 Mon Sep 17 00:00:00 2001 From: ccx1024cc <1261138729@qq.com> Date: Sat, 10 Dec 2016 14:01:34 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A8=E7=BB=93=E6=9E=84=E5=9F=BA=E6=9C=AC?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AE=8C=E6=88=90=EF=BC=8C=E5=90=8E=E7=BB=AD?= =?UTF-8?q?=E8=A1=A8=E5=BB=BA=E7=AB=8B=E6=A0=BC=E5=BC=8F=E5=8F=82=E7=85=A7?= =?UTF-8?q?=E6=9C=AC=E6=AC=A1=E6=8F=90=E4=BA=A4=E5=86=85=E5=AE=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .rake_tasks~ | 39 ++++++++++ app/models/comment.rb | 3 + app/models/mission.rb | 4 + app/models/note.rb | 3 + app/models/project.rb | 3 + app/models/share.rb | 2 + app/models/user.rb | 6 ++ db/migrate/20161210043747_create_users.rb | 11 +++ db/migrate/20161210044025_create_projects.rb | 10 +++ db/migrate/20161210044843_create_missions.rb | 12 +++ db/migrate/20161210045206_create_comments.rb | 10 +++ db/migrate/20161210045652_create_shares.rb | 9 +++ db/migrate/20161210045735_create_notes.rb | 10 +++ ...0040_drop_tables_not_named_conventional.rb | 11 +++ ...2_rename_mission_user_to_missions_users.rb | 5 ++ ...3_rename_project_user_to_projects_users.rb | 5 ++ db/schema.rb | 74 +++++++++++++++++++ test/fixtures/comments.yml | 9 +++ test/fixtures/missions.yml | 13 ++++ test/fixtures/notes.yml | 9 +++ test/fixtures/projects.yml | 9 +++ test/fixtures/shares.yml | 7 ++ test/fixtures/users.yml | 11 +++ test/models/comment_test.rb | 7 ++ test/models/mission_test.rb | 7 ++ test/models/note_test.rb | 7 ++ test/models/project_test.rb | 7 ++ test/models/share_test.rb | 7 ++ test/models/user_test.rb | 7 ++ 29 files changed, 317 insertions(+) create mode 100644 .rake_tasks~ create mode 100644 app/models/comment.rb create mode 100644 app/models/mission.rb create mode 100644 app/models/note.rb create mode 100644 app/models/project.rb create mode 100644 app/models/share.rb create mode 100644 app/models/user.rb create mode 100644 db/migrate/20161210043747_create_users.rb create mode 100644 db/migrate/20161210044025_create_projects.rb create mode 100644 db/migrate/20161210044843_create_missions.rb create mode 100644 db/migrate/20161210045206_create_comments.rb create mode 100644 db/migrate/20161210045652_create_shares.rb create mode 100644 db/migrate/20161210045735_create_notes.rb create mode 100644 db/migrate/20161210050040_drop_tables_not_named_conventional.rb create mode 100644 db/migrate/20161210055342_rename_mission_user_to_missions_users.rb create mode 100644 db/migrate/20161210055513_rename_project_user_to_projects_users.rb create mode 100644 db/schema.rb create mode 100644 test/fixtures/comments.yml create mode 100644 test/fixtures/missions.yml create mode 100644 test/fixtures/notes.yml create mode 100644 test/fixtures/projects.yml create mode 100644 test/fixtures/shares.yml create mode 100644 test/fixtures/users.yml create mode 100644 test/models/comment_test.rb create mode 100644 test/models/mission_test.rb create mode 100644 test/models/note_test.rb create mode 100644 test/models/project_test.rb create mode 100644 test/models/share_test.rb create mode 100644 test/models/user_test.rb diff --git a/.rake_tasks~ b/.rake_tasks~ new file mode 100644 index 0000000..9bae174 --- /dev/null +++ b/.rake_tasks~ @@ -0,0 +1,39 @@ +about +assets:clean[keep] +assets:clobber +assets:environment +assets:precompile +cache_digests:dependencies +cache_digests:nested_dependencies +db:create +db:drop +db:fixtures:load +db:migrate +db:migrate:status +db:rollback +db:schema:cache:clear +db:schema:cache:dump +db:schema:dump +db:schema:load +db:seed +db:setup +db:structure:dump +db:structure:load +db:version +doc:app +log:clear +middleware +notes +notes:custom +rails:template +rails:update +routes +secret +stats +test +test:all +test:all:db +test:db +time:zones:all +tmp:clear +tmp:create diff --git a/app/models/comment.rb b/app/models/comment.rb new file mode 100644 index 0000000..a8c1dc4 --- /dev/null +++ b/app/models/comment.rb @@ -0,0 +1,3 @@ +class Comment < ActiveRecord::Base + belongs_to :mission +end diff --git a/app/models/mission.rb b/app/models/mission.rb new file mode 100644 index 0000000..c214e82 --- /dev/null +++ b/app/models/mission.rb @@ -0,0 +1,4 @@ +class Mission < ActiveRecord::Base + has_and_belongs_to_many :users + has_many :comments +end diff --git a/app/models/note.rb b/app/models/note.rb new file mode 100644 index 0000000..daccdaf --- /dev/null +++ b/app/models/note.rb @@ -0,0 +1,3 @@ +class Note < ActiveRecord::Base + belongs_to :user +end diff --git a/app/models/project.rb b/app/models/project.rb new file mode 100644 index 0000000..967bbbc --- /dev/null +++ b/app/models/project.rb @@ -0,0 +1,3 @@ +class Project < ActiveRecord::Base + has_and_belongs_to_many :users +end diff --git a/app/models/share.rb b/app/models/share.rb new file mode 100644 index 0000000..9fb2c82 --- /dev/null +++ b/app/models/share.rb @@ -0,0 +1,2 @@ +class Share < ActiveRecord::Base +end diff --git a/app/models/user.rb b/app/models/user.rb new file mode 100644 index 0000000..dd6c597 --- /dev/null +++ b/app/models/user.rb @@ -0,0 +1,6 @@ +class User < ActiveRecord::Base + has_and_belongs_to_many :projects + has_and_belongs_to_many :missions + + has_many :notes +end diff --git a/db/migrate/20161210043747_create_users.rb b/db/migrate/20161210043747_create_users.rb new file mode 100644 index 0000000..b59a0ef --- /dev/null +++ b/db/migrate/20161210043747_create_users.rb @@ -0,0 +1,11 @@ +class CreateUsers < ActiveRecord::Migration + def change + create_table :users do |t| + t.string :name + t.string :password_digest + t.string :email + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20161210044025_create_projects.rb b/db/migrate/20161210044025_create_projects.rb new file mode 100644 index 0000000..2d0e2da --- /dev/null +++ b/db/migrate/20161210044025_create_projects.rb @@ -0,0 +1,10 @@ +class CreateProjects < ActiveRecord::Migration + def change + create_table :projects do |t| + t.string :name + t.string :content + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20161210044843_create_missions.rb b/db/migrate/20161210044843_create_missions.rb new file mode 100644 index 0000000..44205e6 --- /dev/null +++ b/db/migrate/20161210044843_create_missions.rb @@ -0,0 +1,12 @@ +class CreateMissions < ActiveRecord::Migration + def change + create_table :missions do |t| + t.string :name + t.datetime :deadline + t.integer :priority + t.string :status + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20161210045206_create_comments.rb b/db/migrate/20161210045206_create_comments.rb new file mode 100644 index 0000000..099e2c7 --- /dev/null +++ b/db/migrate/20161210045206_create_comments.rb @@ -0,0 +1,10 @@ +class CreateComments < ActiveRecord::Migration + def change + create_table :comments do |t| + t.string :content + t.references :mission, index: true, foreign_key: true + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20161210045652_create_shares.rb b/db/migrate/20161210045652_create_shares.rb new file mode 100644 index 0000000..e5a8b6e --- /dev/null +++ b/db/migrate/20161210045652_create_shares.rb @@ -0,0 +1,9 @@ +class CreateShares < ActiveRecord::Migration + def change + create_table :shares do |t| + t.string :content + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20161210045735_create_notes.rb b/db/migrate/20161210045735_create_notes.rb new file mode 100644 index 0000000..0604823 --- /dev/null +++ b/db/migrate/20161210045735_create_notes.rb @@ -0,0 +1,10 @@ +class CreateNotes < ActiveRecord::Migration + def change + create_table :notes do |t| + t.string :content + t.references :user, index: true, foreign_key: true + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20161210050040_drop_tables_not_named_conventional.rb b/db/migrate/20161210050040_drop_tables_not_named_conventional.rb new file mode 100644 index 0000000..c74784e --- /dev/null +++ b/db/migrate/20161210050040_drop_tables_not_named_conventional.rb @@ -0,0 +1,11 @@ +class DropTablesNotNamedConventional < ActiveRecord::Migration + def change + drop_table :coment + drop_table :mission + drop_table :mission_coment + drop_table :note + drop_table :project + drop_table :share + drop_table :user + end +end diff --git a/db/migrate/20161210055342_rename_mission_user_to_missions_users.rb b/db/migrate/20161210055342_rename_mission_user_to_missions_users.rb new file mode 100644 index 0000000..966a32f --- /dev/null +++ b/db/migrate/20161210055342_rename_mission_user_to_missions_users.rb @@ -0,0 +1,5 @@ +class RenameMissionUserToMissionsUsers < ActiveRecord::Migration + def change + rename_table :mission_user, :missions_users + end +end diff --git a/db/migrate/20161210055513_rename_project_user_to_projects_users.rb b/db/migrate/20161210055513_rename_project_user_to_projects_users.rb new file mode 100644 index 0000000..ca6b94c --- /dev/null +++ b/db/migrate/20161210055513_rename_project_user_to_projects_users.rb @@ -0,0 +1,5 @@ +class RenameProjectUserToProjectsUsers < ActiveRecord::Migration + def change + rename_table :project_user, :projects_users + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 0000000..af0a81a --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,74 @@ +# encoding: UTF-8 +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 20161210055513) do + + create_table "comments", force: :cascade do |t| + t.string "content" + t.integer "mission_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "comments", ["mission_id"], name: "index_comments_on_mission_id" + + create_table "missions", force: :cascade do |t| + t.string "name" + t.datetime "deadline" + t.integer "priority" + t.string "status" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "missions_users", id: false, force: :cascade do |t| + t.integer "mission_id" + t.integer "user_id" + end + + create_table "notes", force: :cascade do |t| + t.string "content" + t.integer "user_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "notes", ["user_id"], name: "index_notes_on_user_id" + + create_table "projects", force: :cascade do |t| + t.string "name" + t.string "content" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "projects_users", id: false, force: :cascade do |t| + t.integer "project_id" + t.integer "user_id" + end + + create_table "shares", force: :cascade do |t| + t.string "content" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "users", force: :cascade do |t| + t.string "name" + t.string "password_digest" + t.string "email" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + +end diff --git a/test/fixtures/comments.yml b/test/fixtures/comments.yml new file mode 100644 index 0000000..1043d0a --- /dev/null +++ b/test/fixtures/comments.yml @@ -0,0 +1,9 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + content: MyString + mission_id: + +two: + content: MyString + mission_id: diff --git a/test/fixtures/missions.yml b/test/fixtures/missions.yml new file mode 100644 index 0000000..7cd9e41 --- /dev/null +++ b/test/fixtures/missions.yml @@ -0,0 +1,13 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + name: MyString + deadline: 2016-12-10 12:48:43 + priority: 1 + status: MyString + +two: + name: MyString + deadline: 2016-12-10 12:48:43 + priority: 1 + status: MyString diff --git a/test/fixtures/notes.yml b/test/fixtures/notes.yml new file mode 100644 index 0000000..01638eb --- /dev/null +++ b/test/fixtures/notes.yml @@ -0,0 +1,9 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + content: + user_id: + +two: + content: + user_id: diff --git a/test/fixtures/projects.yml b/test/fixtures/projects.yml new file mode 100644 index 0000000..2a0a458 --- /dev/null +++ b/test/fixtures/projects.yml @@ -0,0 +1,9 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + name: MyString + content: MyString + +two: + name: MyString + content: MyString diff --git a/test/fixtures/shares.yml b/test/fixtures/shares.yml new file mode 100644 index 0000000..ab8d999 --- /dev/null +++ b/test/fixtures/shares.yml @@ -0,0 +1,7 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + content: MyString + +two: + content: MyString diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml new file mode 100644 index 0000000..b4f1bcc --- /dev/null +++ b/test/fixtures/users.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + name: MyString + password_digest: MyString + email: MyString + +two: + name: MyString + password_digest: MyString + email: MyString diff --git a/test/models/comment_test.rb b/test/models/comment_test.rb new file mode 100644 index 0000000..b6d6131 --- /dev/null +++ b/test/models/comment_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class CommentTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/mission_test.rb b/test/models/mission_test.rb new file mode 100644 index 0000000..d49e76e --- /dev/null +++ b/test/models/mission_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class MissionTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/note_test.rb b/test/models/note_test.rb new file mode 100644 index 0000000..7bbab53 --- /dev/null +++ b/test/models/note_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class NoteTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/project_test.rb b/test/models/project_test.rb new file mode 100644 index 0000000..0821e1f --- /dev/null +++ b/test/models/project_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class ProjectTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/share_test.rb b/test/models/share_test.rb new file mode 100644 index 0000000..199d270 --- /dev/null +++ b/test/models/share_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class ShareTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/user_test.rb b/test/models/user_test.rb new file mode 100644 index 0000000..82f61e0 --- /dev/null +++ b/test/models/user_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class UserTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end