group_removed_users table to forbid users joining once removed

This commit is contained in:
2458773093 2019-07-16 08:46:03 +03:00
parent c56a8914f3
commit 520c125e21
5 changed files with 51 additions and 6 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,2 @@
Fabricator(:group_removed_account) do
end

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe GroupRemovedAccount, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end