Add missing fks to api_secrets, listings and identities (#4997) [deploy]
This commit is contained in:
parent
8a5180f6dc
commit
e62f5ada21
3 changed files with 20 additions and 2 deletions
|
|
@ -0,0 +1,7 @@
|
|||
class AddMissingForeignKeysApiSecretsListingsIdentities < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_foreign_key :api_secrets, :users, on_delete: :cascade
|
||||
add_foreign_key :classified_listings, :users, on_delete: :cascade
|
||||
add_foreign_key :identities, :users, on_delete: :cascade
|
||||
end
|
||||
end
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2019_12_03_114809) do
|
||||
ActiveRecord::Schema.define(version: 2019_12_03_160028) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
|
|
@ -1204,11 +1204,14 @@ ActiveRecord::Schema.define(version: 2019_12_03_114809) do
|
|||
t.index ["user_id"], name: "index_webhook_endpoints_on_user_id"
|
||||
end
|
||||
|
||||
add_foreign_key "api_secrets", "users", on_delete: :cascade
|
||||
add_foreign_key "audit_logs", "users"
|
||||
add_foreign_key "badge_achievements", "badges"
|
||||
add_foreign_key "badge_achievements", "users"
|
||||
add_foreign_key "chat_channel_memberships", "chat_channels"
|
||||
add_foreign_key "chat_channel_memberships", "users"
|
||||
add_foreign_key "classified_listings", "users", on_delete: :cascade
|
||||
add_foreign_key "identities", "users", on_delete: :cascade
|
||||
add_foreign_key "messages", "chat_channels"
|
||||
add_foreign_key "messages", "users"
|
||||
add_foreign_key "oauth_access_grants", "oauth_applications", column: "application_id"
|
||||
|
|
|
|||
|
|
@ -5,7 +5,15 @@ RSpec.describe Identity, type: :model do
|
|||
it { is_expected.to validate_presence_of(:uid) }
|
||||
it { is_expected.to validate_presence_of(:provider) }
|
||||
it { is_expected.to validate_uniqueness_of(:uid).scoped_to(:provider) }
|
||||
it { is_expected.to validate_uniqueness_of(:user_id).scoped_to(:provider) }
|
||||
|
||||
it do
|
||||
# rubocop:disable RSpec/NamedSubject
|
||||
# see <https://github.com/thoughtbot/shoulda-matchers/issues/682>
|
||||
subject.user = create(:user)
|
||||
expect(subject).to validate_uniqueness_of(:user_id).scoped_to(:provider)
|
||||
# rubocop:enable RSpec/NamedSubject
|
||||
end
|
||||
|
||||
it { is_expected.to validate_inclusion_of(:provider).in_array(%w[github twitter]) }
|
||||
it { is_expected.to serialize(:auth_data_dump) }
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue