Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/referral/attribution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# id :bigint not null, primary key
# created_at :datetime not null
# updated_at :datetime not null
# referral_link_id :bigint
# referral_link_id :bigint not null
# referral_program_id :bigint not null
# user_id :bigint not null
#
Expand Down
2 changes: 1 addition & 1 deletion app/models/referral/program.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# name :string not null
# created_at :datetime not null
# updated_at :datetime not null
# creator_id :bigint
# creator_id :bigint not null
#
# Indexes
#
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class MakeReferralLinkIdNotNullOnReferralAttributions < ActiveRecord::Migration[8.0]
def change
add_check_constraint :referral_attributions, "referral_link_id IS NOT NULL", name: "referral_attributions_referral_link_id_null", validate: false
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class MakeCreatorIdNotNullOnReferralPrograms < ActiveRecord::Migration[8.0]
def change
add_check_constraint :referral_programs, "creator_id IS NOT NULL", name: "referral_programs_creator_id_null", validate: false
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class ValidateMakeReferralLinkIdNotNullOnReferralAttributions < ActiveRecord::Migration[8.0]
def up
validate_check_constraint :referral_attributions, name: "referral_attributions_referral_link_id_null"
change_column_null :referral_attributions, :referral_link_id, false
remove_check_constraint :referral_attributions, name: "referral_attributions_referral_link_id_null"
end

def down
add_check_constraint :referral_attributions, "referral_link_id IS NOT NULL", name: "referral_attributions_referral_link_id_null", validate: false
change_column_null :referral_attributions, :referral_link_id, true
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class ValidateMakeCreatorIdNotNullOnReferralPrograms < ActiveRecord::Migration[8.0]
def up
validate_check_constraint :referral_programs, name: "referral_programs_creator_id_null"
change_column_null :referral_programs, :creator_id, false
remove_check_constraint :referral_programs, name: "referral_programs_creator_id_null"
end

def down
add_check_constraint :referral_programs, "creator_id IS NOT NULL", name: "referral_programs_creator_id_null", validate: false
change_column_null :referral_programs, :creator_id, true
end
end
6 changes: 3 additions & 3 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[8.0].define(version: 2025_12_05_035167) do
ActiveRecord::Schema[8.0].define(version: 2025_12_05_044631) do
create_schema "google_sheets"

# These are extensions that must be enabled in order to support this database
Expand Down Expand Up @@ -1981,7 +1981,7 @@

create_table "referral_attributions", force: :cascade do |t|
t.datetime "created_at", null: false
t.bigint "referral_link_id"
t.bigint "referral_link_id", null: false
t.bigint "referral_program_id", null: false
t.datetime "updated_at", null: false
t.bigint "user_id", null: false
Expand All @@ -2005,7 +2005,7 @@
create_table "referral_programs", force: :cascade do |t|
t.string "background_image_url"
t.datetime "created_at", null: false
t.bigint "creator_id"
t.bigint "creator_id", null: false
t.text "login_body_text"
t.string "login_header_text"
t.string "login_text_color"
Expand Down