diff --git a/app/models/group_removed_account.rb b/app/models/group_removed_account.rb new file mode 100644 index 00000000..0f509708 --- /dev/null +++ b/app/models/group_removed_account.rb @@ -0,0 +1,13 @@ +# == Schema Information +# +# Table name: group_removed_accounts +# +# id :bigint(8) not null, primary key +# group_id :bigint(8) not null +# account_id :bigint(8) not null +# created_at :datetime not null +# updated_at :datetime not null +# + +class GroupRemovedAccount < ApplicationRecord +end diff --git a/db/migrate/20190716173227_create_group_removed_accounts.rb b/db/migrate/20190716173227_create_group_removed_accounts.rb new file mode 100644 index 00000000..101acae1 --- /dev/null +++ b/db/migrate/20190716173227_create_group_removed_accounts.rb @@ -0,0 +1,12 @@ +class CreateGroupRemovedAccounts < ActiveRecord::Migration[5.2] + def change + create_table :group_removed_accounts do |t| + t.belongs_to :group, foreign_key: { on_delete: :cascade }, null: false + t.belongs_to :account, foreign_key: { on_delete: :cascade }, null: false + t.timestamps + end + + add_index :group_removed_accounts, [:account_id, :group_id], unique: true + add_index :group_removed_accounts, [:group_id, :account_id] + end +end diff --git a/db/schema.rb b/db/schema.rb index 0004c21a..a27da0bf 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2019_06_07_000211) do +ActiveRecord::Schema.define(version: 2019_07_16_173227) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -93,7 +93,7 @@ ActiveRecord::Schema.define(version: 2019_06_07_000211) do t.bigint "account_id" t.string "image_file_name" t.string "image_content_type" - t.bigint "image_file_size" + t.integer "image_file_size" t.datetime "image_updated_at" t.datetime "created_at", null: false t.datetime "updated_at", null: false @@ -157,10 +157,10 @@ ActiveRecord::Schema.define(version: 2019_06_07_000211) do t.string "actor_type" t.boolean "discoverable" t.string "also_known_as", array: true - t.datetime "silenced_at" - t.datetime "suspended_at" t.boolean "is_pro", default: false, null: false t.datetime "pro_expires_at" + t.datetime "silenced_at" + t.datetime "suspended_at" t.boolean "is_verified", default: false, null: false t.boolean "is_donor", default: false, null: false t.boolean "is_investor", default: false, null: false @@ -333,6 +333,17 @@ ActiveRecord::Schema.define(version: 2019_06_07_000211) do t.index ["group_id"], name: "index_group_accounts_on_group_id" end + create_table "group_removed_accounts", force: :cascade do |t| + t.bigint "group_id", null: false + t.bigint "account_id", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["account_id", "group_id"], name: "index_group_removed_accounts_on_account_id_and_group_id", unique: true + t.index ["account_id"], name: "index_group_removed_accounts_on_account_id" + t.index ["group_id", "account_id"], name: "index_group_removed_accounts_on_group_id_and_account_id" + t.index ["group_id"], name: "index_group_removed_accounts_on_group_id" + end + create_table "groups", force: :cascade do |t| t.bigint "account_id" t.string "title", null: false @@ -645,8 +656,8 @@ ActiveRecord::Schema.define(version: 2019_06_07_000211) do create_table "status_pins", force: :cascade do |t| t.bigint "account_id", null: false t.bigint "status_id", null: false - t.datetime "created_at", default: -> { "now()" }, null: false - t.datetime "updated_at", default: -> { "now()" }, null: false + t.datetime "created_at", default: -> { "CURRENT_TIMESTAMP" }, null: false + t.datetime "updated_at", default: -> { "CURRENT_TIMESTAMP" }, null: false t.index ["account_id", "status_id"], name: "index_status_pins_on_account_id_and_status_id", unique: true end @@ -849,6 +860,8 @@ ActiveRecord::Schema.define(version: 2019_06_07_000211) do add_foreign_key "follows", "accounts", name: "fk_32ed1b5560", on_delete: :cascade add_foreign_key "group_accounts", "accounts", on_delete: :cascade add_foreign_key "group_accounts", "groups", on_delete: :cascade + add_foreign_key "group_removed_accounts", "accounts", on_delete: :cascade + add_foreign_key "group_removed_accounts", "groups", on_delete: :cascade add_foreign_key "identities", "users", name: "fk_bea040f377", on_delete: :cascade add_foreign_key "imports", "accounts", name: "fk_6db1b6e408", on_delete: :cascade add_foreign_key "invites", "users", on_delete: :cascade diff --git a/spec/fabricators/group_removed_account_fabricator.rb b/spec/fabricators/group_removed_account_fabricator.rb new file mode 100644 index 00000000..c01c2df3 --- /dev/null +++ b/spec/fabricators/group_removed_account_fabricator.rb @@ -0,0 +1,2 @@ +Fabricator(:group_removed_account) do +end diff --git a/spec/models/group_removed_account_spec.rb b/spec/models/group_removed_account_spec.rb new file mode 100644 index 00000000..098f7c18 --- /dev/null +++ b/spec/models/group_removed_account_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe GroupRemovedAccount, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end