Add AndroidDeviceRegistrationToken model belonging to user

This commit is contained in:
redfast00 2019-05-08 21:46:17 +02:00
parent a727dfb1dd
commit cf5c02626d
No known key found for this signature in database
GPG key ID: 5946E0E34FD0553C
6 changed files with 34 additions and 1 deletions

View file

@ -0,0 +1,3 @@
class AndroidDeviceRegistrationToken < ActiveRecord::Base
belongs_to :user
end

View file

@ -23,6 +23,7 @@ class User < ActiveRecord::Base
has_many :outgoing_requests,
class_name: 'Request', foreign_key: 'creditor_id'
has_many :notifications
has_many :android_device_registration_tokens, class_name: 'AndroidDeviceRegistrationToken', foreign_key: 'user_id'
has_many :issued_transactions, as: :issuer, class_name: 'Transaction'

View file

@ -0,0 +1,10 @@
class CreateAndroidDeviceRegistrationTokens < ActiveRecord::Migration[5.2]
def change
create_table :android_device_registration_tokens do |t|
t.string :token
t.belongs_to :user, foreign_key: true
t.timestamps
end
end
end

View file

@ -10,7 +10,15 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2018_06_20_161021) do
ActiveRecord::Schema.define(version: 2019_05_08_192738) do
create_table "android_device_registration_tokens", force: :cascade do |t|
t.string "token"
t.integer "user_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["user_id"], name: "index_android_device_registration_tokens_on_user_id"
end
create_table "clients", force: :cascade do |t|
t.string "name", null: false

View file

@ -0,0 +1,6 @@
FactoryGirl.define do
factory :android_device_registration_token do
token "MyString"
user nil
end
end

View file

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