Add zap model, user relation
This commit is contained in:
parent
619bd954b7
commit
49d24990b4
@ -17,16 +17,15 @@ class User < ApplicationRecord
|
|||||||
has_one :invitation, inverse_of: :invitee, foreign_key: 'invited_user_id'
|
has_one :invitation, inverse_of: :invitee, foreign_key: 'invited_user_id'
|
||||||
has_one :inviter, through: :invitation, source: :user
|
has_one :inviter, through: :invitation, source: :user
|
||||||
has_many :invitees, through: :invitations
|
has_many :invitees, through: :invitations
|
||||||
|
|
||||||
has_many :donations, dependent: :nullify
|
has_many :donations, dependent: :nullify
|
||||||
|
has_many :remote_storage_authorizations
|
||||||
|
has_many :zaps
|
||||||
|
|
||||||
has_one :lndhub_user, class_name: "LndhubUser", inverse_of: "user",
|
has_one :lndhub_user, class_name: "LndhubUser", inverse_of: "user",
|
||||||
primary_key: "ln_account", foreign_key: "login"
|
primary_key: "ln_account", foreign_key: "login"
|
||||||
|
|
||||||
has_many :accounts, through: :lndhub_user
|
has_many :accounts, through: :lndhub_user
|
||||||
|
|
||||||
has_many :remote_storage_authorizations
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Validations
|
# Validations
|
||||||
#
|
#
|
||||||
|
3
app/models/zap.rb
Normal file
3
app/models/zap.rb
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
class Zap < ApplicationRecord
|
||||||
|
belongs_to :user
|
||||||
|
end
|
13
db/migrate/20240422171653_create_zaps.rb
Normal file
13
db/migrate/20240422171653_create_zaps.rb
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
class CreateZaps < ActiveRecord::Migration[7.1]
|
||||||
|
def change
|
||||||
|
create_table :zaps do |t|
|
||||||
|
t.references :user, null: false, foreign_key: true
|
||||||
|
t.json :request
|
||||||
|
t.json :receipt
|
||||||
|
t.text :payment_request
|
||||||
|
t.bigint :amount
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
14
db/schema.rb
14
db/schema.rb
@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema[7.1].define(version: 2024_03_16_153558) do
|
ActiveRecord::Schema[7.1].define(version: 2024_04_22_171653) do
|
||||||
create_table "active_storage_attachments", force: :cascade do |t|
|
create_table "active_storage_attachments", force: :cascade do |t|
|
||||||
t.string "name", null: false
|
t.string "name", null: false
|
||||||
t.string "record_type", null: false
|
t.string "record_type", null: false
|
||||||
@ -136,8 +136,20 @@ ActiveRecord::Schema[7.1].define(version: 2024_03_16_153558) do
|
|||||||
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "zaps", force: :cascade do |t|
|
||||||
|
t.integer "user_id", null: false
|
||||||
|
t.json "request"
|
||||||
|
t.json "receipt"
|
||||||
|
t.text "payment_request"
|
||||||
|
t.bigint "amount"
|
||||||
|
t.datetime "created_at", null: false
|
||||||
|
t.datetime "updated_at", null: false
|
||||||
|
t.index ["user_id"], name: "index_zaps_on_user_id"
|
||||||
|
end
|
||||||
|
|
||||||
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
|
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
|
||||||
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
|
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
|
||||||
add_foreign_key "remote_storage_authorizations", "app_catalog_web_apps", column: "web_app_id"
|
add_foreign_key "remote_storage_authorizations", "app_catalog_web_apps", column: "web_app_id"
|
||||||
add_foreign_key "remote_storage_authorizations", "users"
|
add_foreign_key "remote_storage_authorizations", "users"
|
||||||
|
add_foreign_key "zaps", "users"
|
||||||
end
|
end
|
||||||
|
7
spec/factories/zaps.rb
Normal file
7
spec/factories/zaps.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
FactoryBot.define do
|
||||||
|
factory :zap do
|
||||||
|
user { nil }
|
||||||
|
request { "" }
|
||||||
|
receipt { "" }
|
||||||
|
end
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user