feat: implement payout system database schema and models

This commit is contained in:
kbe
2025-09-16 23:52:26 +02:00
parent e5ed1a34dd
commit 0399761fb3
23 changed files with 421 additions and 5 deletions

View File

@@ -52,6 +52,8 @@ class DeviseCreateUsers < ActiveRecord::Migration[8.0]
# Add onboarding check on user model
t.boolean :onboarding_completed, default: false, null: false
# add_column :users, :stripe_connected_account_id, :string
t.timestamps null: false
end

View File

@@ -0,0 +1,16 @@
class CreateEarnings < ActiveRecord::Migration[8.0]
def change
create_table :earnings do |t|
t.integer :amount_cents
t.integer :fee_cents
t.integer :status
t.string :stripe_payout_id
t.references :event, null: false, foreign_key: false, index: true
t.references :user, null: false, foreign_key: false, index: true
t.references :order, null: false, foreign_key: false, index: true
t.timestamps
end
end
end

View File

@@ -0,0 +1,6 @@
class AddPayoutFieldsToEvents < ActiveRecord::Migration[8.0]
def change
add_column :events, :payout_requested_at, :datetime
add_column :events, :payout_status, :integer
end
end

View File

@@ -0,0 +1,5 @@
class AddNetAmountToEarnings < ActiveRecord::Migration[8.0]
def change
add_column :earnings, :net_amount_cents, :integer
end
end

View File

@@ -0,0 +1,6 @@
class AddIndexToStripeConnectedAccountIdOnUsers < ActiveRecord::Migration[8.0]
def change
add_column :stripe_connected_account_id_on_users, :stripe_connected_account_id, :string
add_index :stripe_connected_account_id_on_users, :stripe_connected_account_id
end
end

View File

@@ -0,0 +1,11 @@
class UpdatePayoutStatusOnEvents < ActiveRecord::Migration[8.0]
def up
change_column_default :events, :payout_status, from: nil, to: 0
add_index :events, :payout_status
end
def down
change_column_default :events, :payout_status, from: 0, to: nil
remove_index :events, :payout_status
end
end

23
db/schema.rb generated
View File

@@ -10,7 +10,23 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[8.0].define(version: 2025_09_11_063815) do
ActiveRecord::Schema[8.0].define(version: 2025_09_16_215119) do
create_table "earnings", charset: "utf8mb4", collation: "utf8mb4_uca1400_ai_ci", force: :cascade do |t|
t.integer "amount_cents"
t.integer "fee_cents"
t.integer "status"
t.string "stripe_payout_id"
t.bigint "event_id", null: false
t.bigint "user_id", null: false
t.bigint "order_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "net_amount_cents"
t.index ["event_id"], name: "index_earnings_on_event_id"
t.index ["order_id"], name: "index_earnings_on_order_id"
t.index ["user_id"], name: "index_earnings_on_user_id"
end
create_table "events", charset: "utf8mb4", collation: "utf8mb4_uca1400_ai_ci", force: :cascade do |t|
t.string "name", null: false
t.string "slug", null: false
@@ -25,9 +41,11 @@ ActiveRecord::Schema[8.0].define(version: 2025_09_11_063815) do
t.decimal "longitude", precision: 10, scale: 6, null: false
t.boolean "featured", default: false, null: false
t.bigint "user_id", null: false
t.boolean "allow_booking_during_event", default: false, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "allow_booking_during_event", default: false, null: false
t.datetime "payout_requested_at"
t.integer "payout_status"
t.index ["featured"], name: "index_events_on_featured"
t.index ["latitude", "longitude"], name: "index_events_on_latitude_and_longitude"
t.index ["state"], name: "index_events_on_state"
@@ -101,6 +119,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_09_11_063815) do
t.boolean "onboarding_completed", default: false, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "stripe_connected_account_id"
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
end