From fa402ef3c4f4fdc6f270009b77ea8fbccf00b42f Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 20 Mar 2020 15:53:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B6=E8=97=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/collection.rb | 3 +++ db/migrate/20200320074850_create_collections.rb | 13 +++++++++++++ spec/models/collection_spec.rb | 5 +++++ 3 files changed, 21 insertions(+) create mode 100644 app/models/collection.rb create mode 100644 db/migrate/20200320074850_create_collections.rb create mode 100644 spec/models/collection_spec.rb diff --git a/app/models/collection.rb b/app/models/collection.rb new file mode 100644 index 000000000..3baf96931 --- /dev/null +++ b/app/models/collection.rb @@ -0,0 +1,3 @@ +class Collection < ApplicationRecord + belongs_to :user +end diff --git a/db/migrate/20200320074850_create_collections.rb b/db/migrate/20200320074850_create_collections.rb new file mode 100644 index 000000000..7bc172c5d --- /dev/null +++ b/db/migrate/20200320074850_create_collections.rb @@ -0,0 +1,13 @@ +class CreateCollections < ActiveRecord::Migration[5.2] + def change + create_table :collections do |t| + t.references :user, index: true + t.integer :container_id + t.string :container_type + + t.timestamps + end + + add_index :collections, [:container_type, :container_id] + end +end diff --git a/spec/models/collection_spec.rb b/spec/models/collection_spec.rb new file mode 100644 index 000000000..284719b0f --- /dev/null +++ b/spec/models/collection_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Collection, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end