feat: implement payout system database schema and models
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
16
db/migrate/20250916212717_create_earnings.rb
Normal file
16
db/migrate/20250916212717_create_earnings.rb
Normal 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
|
||||
6
db/migrate/20250916215118_add_payout_fields_to_events.rb
Normal file
6
db/migrate/20250916215118_add_payout_fields_to_events.rb
Normal 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
|
||||
5
db/migrate/20250916215119_add_net_amount_to_earnings.rb
Normal file
5
db/migrate/20250916215119_add_net_amount_to_earnings.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddNetAmountToEarnings < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
add_column :earnings, :net_amount_cents, :integer
|
||||
end
|
||||
end
|
||||
@@ -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
|
||||
11
db/migrate/20250916215130_update_payout_status_on_events.rb
Normal file
11
db/migrate/20250916215130_update_payout_status_on_events.rb
Normal 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
23
db/schema.rb
generated
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user