Add web push subscription model

This commit is contained in:
Karina Kwiatek 2022-09-11 20:10:21 +02:00
parent 4e08f035d1
commit 32ab9267ec
4 changed files with 25 additions and 0 deletions

View File

@ -42,6 +42,7 @@ class User < ApplicationRecord
has_many :subscriptions, dependent: :destroy_async
has_many :totp_recovery_codes, dependent: :destroy_async
has_many :web_push_subscriptions, dependent: :destroy_async
has_one :profile, dependent: :destroy
has_one :theme, dependent: :destroy

View File

@ -0,0 +1,5 @@
# frozen_string_literal: true
class WebPushSubscription < ApplicationRecord
belongs_to :user
end

View File

@ -0,0 +1,11 @@
class CreateWebPushSubscriptions < ActiveRecord::Migration[6.1]
def change
create_table :web_push_subscriptions do |t|
t.bigint :user_id, null: false
t.json :subscription
t.timestamps
end
add_index :web_push_subscriptions, :user_id
end
end

View File

@ -382,5 +382,13 @@ ActiveRecord::Schema.define(version: 2022_12_27_065923) do
t.index ["user_id"], name: "index_users_roles_on_user_id"
end
create_table "web_push_subscriptions", force: :cascade do |t|
t.bigint "user_id", null: false
t.json "subscription"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["user_id"], name: "index_web_push_subscriptions_on_user_id"
end
add_foreign_key "profiles", "users"
end