Skip to content
Draft
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 backend/db/migrate/20160101154821_create_extensions.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateExtensions < ActiveRecord::Migration
class CreateExtensions < ActiveRecord::Migration[7.1]
def change
enable_extension "pg_trgm"
end
Expand Down
2 changes: 1 addition & 1 deletion backend/db/migrate/20160106154821_create_users.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateUsers < ActiveRecord::Migration
class CreateUsers < ActiveRecord::Migration[7.1]
def change
create_table :users do |t|
## Database authenticatable
Expand Down
2 changes: 1 addition & 1 deletion backend/db/migrate/20160119185831_create_profiles.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateProfiles < ActiveRecord::Migration
class CreateProfiles < ActiveRecord::Migration[7.1]
def change
create_table :profiles do |t|
t.belongs_to :user, index: true, foreign_key: true
Expand Down
2 changes: 1 addition & 1 deletion backend/db/migrate/20160128112500_create_conditions.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateConditions < ActiveRecord::Migration
class CreateConditions < ActiveRecord::Migration[7.1]
def up
create_table :conditions do |t|
t.boolean :global, default: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateUserConditions < ActiveRecord::Migration
class CreateUserConditions < ActiveRecord::Migration[7.1]
def change
create_table :user_conditions do |t|
t.belongs_to :user, index: true, foreign_key: true
Expand Down
2 changes: 1 addition & 1 deletion backend/db/migrate/20160128191053_create_symptoms.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateSymptoms < ActiveRecord::Migration
class CreateSymptoms < ActiveRecord::Migration[7.1]
def up
create_table :symptoms do |t|
t.boolean :global, default: true
Expand Down
2 changes: 1 addition & 1 deletion backend/db/migrate/20160128191329_create_user_symptoms.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateUserSymptoms < ActiveRecord::Migration
class CreateUserSymptoms < ActiveRecord::Migration[7.1]
def change
create_table :user_symptoms do |t|
t.belongs_to :user, index: true, foreign_key: true
Expand Down
2 changes: 1 addition & 1 deletion backend/db/migrate/20160128210332_create_trackings.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateTrackings < ActiveRecord::Migration
class CreateTrackings < ActiveRecord::Migration[7.1]
def change
create_table :trackings do |t|
t.belongs_to :user, index: true, foreign_key: true
Expand Down
2 changes: 1 addition & 1 deletion backend/db/migrate/20160129063945_create_treatments.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateTreatments < ActiveRecord::Migration
class CreateTreatments < ActiveRecord::Migration[7.1]
def up
create_table :treatments do |t|
t.boolean :global, default: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateUserTreatments < ActiveRecord::Migration
class CreateUserTreatments < ActiveRecord::Migration[7.1]
def change
create_table :user_treatments do |t|
t.belongs_to :user, index: true, foreign_key: true
Expand Down
2 changes: 1 addition & 1 deletion backend/db/migrate/20160211105611_create_tags.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateTags < ActiveRecord::Migration
class CreateTags < ActiveRecord::Migration[7.1]
def up
create_table :tags do |t|
t.timestamps null: false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddDemographicsToProfiles < ActiveRecord::Migration
class AddDemographicsToProfiles < ActiveRecord::Migration[7.1]
def change
add_column :profiles, :ethnicity_ids_string, :string
add_column :profiles, :day_habit_id, :string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class EnableHstoreExtension < ActiveRecord::Migration
class EnableHstoreExtension < ActiveRecord::Migration[7.1]
def change
enable_extension "hstore"
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddMostRecentDosesToProfiles < ActiveRecord::Migration
class AddMostRecentDosesToProfiles < ActiveRecord::Migration[7.1]
def change
add_column :profiles, :most_recent_doses, :hstore
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateTrackableUsages < ActiveRecord::Migration
class CreateTrackableUsages < ActiveRecord::Migration[7.1]
def change
create_table :trackable_usages do |t|
t.belongs_to :user, index: true, foreign_key: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddTrackableUsagesCounts < ActiveRecord::Migration
class AddTrackableUsagesCounts < ActiveRecord::Migration[7.1]
def change
add_column :conditions, :trackable_usages_count, :integer, default: 0
add_column :symptoms, :trackable_usages_count, :integer, default: 0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddScreenNameToProfile < ActiveRecord::Migration
class AddScreenNameToProfile < ActiveRecord::Migration[7.1]
def change
add_column :profiles, :screen_name, :string
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddMostRecentPositionsToProfiles < ActiveRecord::Migration
class AddMostRecentPositionsToProfiles < ActiveRecord::Migration[7.1]
def change
add_column :profiles, :most_recent_conditions_positions, :hstore
add_column :profiles, :most_recent_symptoms_positions, :hstore
Expand Down
2 changes: 1 addition & 1 deletion backend/db/migrate/20161206135858_create_foods.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateFoods < ActiveRecord::Migration
class CreateFoods < ActiveRecord::Migration[7.1]
def change
create_table :foods do |t|
t.string :ndb_no
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddLongDescVectorIndexOnFoodTranslations < ActiveRecord::Migration
class AddLongDescVectorIndexOnFoodTranslations < ActiveRecord::Migration[7.1]
disable_ddl_transaction!

def up
Expand Down
2 changes: 1 addition & 1 deletion backend/db/migrate/20161216123757_create_weathers.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateWeathers < ActiveRecord::Migration
class CreateWeathers < ActiveRecord::Migration[7.1]
def change
create_table :weathers do |t|
t.date :date
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddPressureAndTemperatureSettingsToProfile < ActiveRecord::Migration
class AddPressureAndTemperatureSettingsToProfile < ActiveRecord::Migration[7.1]
def change
add_column :profiles, :pressure_units, :integer, default: 0
add_column :profiles, :temperature_units, :integer, default: 0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddBetaTesterToProfile < ActiveRecord::Migration
class AddBetaTesterToProfile < ActiveRecord::Migration[7.1]
def change
add_column :profiles, :beta_tester, :boolean, default: false
end
Expand Down
2 changes: 1 addition & 1 deletion backend/db/migrate/20170504065043_create_crono_jobs.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateCronoJobs < ActiveRecord::Migration
class CreateCronoJobs < ActiveRecord::Migration[7.1]
def self.up
create_table :crono_jobs do |t|
t.string :job_id, null: false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddNotifyToProfiles < ActiveRecord::Migration
class AddNotifyToProfiles < ActiveRecord::Migration[7.1]
def change
add_column :profiles, :notify, :boolean, default: true
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddNotifyTokenToProfiles < ActiveRecord::Migration
class AddNotifyTokenToProfiles < ActiveRecord::Migration[7.1]
def up
add_column :profiles, :notify_token, :string
Profile.find_each(batch_size: 500) do |profile|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddSlugNameToProfiles < ActiveRecord::Migration
class AddSlugNameToProfiles < ActiveRecord::Migration[7.1]
def up
add_column :profiles, :slug_name, :string
add_index :profiles, :slug_name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddNotifyTopPostsToProfile < ActiveRecord::Migration
class AddNotifyTopPostsToProfile < ActiveRecord::Migration[7.1]
def change
add_column :profiles, :notify_top_posts, :boolean, default: true
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddGlobalToFoodsAndTags < ActiveRecord::Migration
class AddGlobalToFoodsAndTags < ActiveRecord::Migration[7.1]
def change
add_column :foods, :global, :boolean, default: true
add_column :tags, :global, :boolean, default: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddTrackableUsageCountToTags < ActiveRecord::Migration
class AddTrackableUsageCountToTags < ActiveRecord::Migration[7.1]
def change
add_column :tags, :trackable_usages_count, :integer, default: 0
end
Expand Down
2 changes: 1 addition & 1 deletion backend/db/migrate/20170731125044_create_user_tags.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateUserTags < ActiveRecord::Migration
class CreateUserTags < ActiveRecord::Migration[7.1]
def change
create_table :user_tags do |t|
t.belongs_to :user, index: true, foreign_key: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddTrackableAbilityToFoods < ActiveRecord::Migration
class AddTrackableAbilityToFoods < ActiveRecord::Migration[7.1]
def change
add_column :foods, :trackable_usages_count, :integer, default: 0

Expand Down
4 changes: 2 additions & 2 deletions backend/db/migrate/20170817154145_create_positions.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
class CreatePositions < ActiveRecord::Migration
class CreatePositions < ActiveRecord::Migration[7.1]
def change
create_table :positions do |t|
t.string :postal_code, null: false
t.string :location_name, null: false
t.decimal :latitude, {precision: 10, scale: 7}
t.decimal :longitude, {precision: 10, scale: 7}
#t.decimal :longitude, {precision: 10, scale: 7}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this causing a problem?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably the migration was failing to go through with the field as is. Can check and confirm.

end
end
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddPositionReferenceToWeather < ActiveRecord::Migration
class AddPositionReferenceToWeather < ActiveRecord::Migration[7.1]
def change
add_reference :weathers, :position, foreign_key: true
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddCheckinReminderToProfiles < ActiveRecord::Migration
class AddCheckinReminderToProfiles < ActiveRecord::Migration[7.1]
def change
add_column :profiles, :checkin_reminder, :boolean, default: false
add_column :profiles, :checkin_reminder_at, :datetime
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddRejectedTypeToProfiles < ActiveRecord::Migration
class AddRejectedTypeToProfiles < ActiveRecord::Migration[7.1]
def change
add_column :profiles, :rejected_type, :string
end
Expand Down
3 changes: 2 additions & 1 deletion backend/lib/tasks/app.rake
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ namespace :app do
if Rails.env.development?
Rake::Task["db:drop"].invoke
Rake::Task["db:create"].invoke
Rake::Task["db:migrate"].invoke
end
Rake::Task["db:structure:load"].invoke
#Rake::Task["db:schema:load"].invoke
Copy link
Author

@lenikadali lenikadali Mar 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to comment out the db:schema:load task, after updating from db:structure:load since this was removed in Rails 6.2, in order to be able to run the rails app:setup command.

The error I got when I tried to run rails db:schema:load independently was:

psql:/app/db/structure.sql:60: ERROR:  relation "ar_internal_metadata" already exists
bin/rails aborted!
failed to execute:
psql --set ON_ERROR_STOP=1 --quiet --no-psqlrc --output /dev/null --file /app/db/structure.sql flaredown_development

Please check the output above for any errors and make sure that `psql` is installed in your PATH and has proper permissions.

/app/lib/tasks/app.rake:47:in `build_database'
/app/lib/tasks/app.rake:32:in `setup'
/app/lib/tasks/app.rake:4:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:schema:load
(See full trace by running task with --trace)

It seems psql needs to be installed in the Rails container in order for the schema loading to work. Not sure why since pg is in the backend/Gemfile and I would think that should cover the database connection needs for the app.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious if it would work as intended if we put the db:migrate here, and then the schema:load within the Rails.env.development? block. I'm not sure if this is ran in our deploy process for production anyway, or this is generally just used for development purposes.

Copy link
Author

@lenikadali lenikadali Aug 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't know since I was running this for development setup purposes 🙃
Maybe the contributors who've deployed Flaredown in production can comment?

Rake::Task["db:seed"].invoke
rescue ::PG::ObjectInUse => e
puts "\n#{e.message}.".red
Expand Down
13 changes: 13 additions & 0 deletions backend/spec/factories/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,22 @@
#

FactoryBot.define do

def initialize_profile
create_profile!(
checkin_reminder: true,
onboarding_step_id: "onboarding-personal",
most_recent_doses: {},
most_recent_conditions_positions: {},
most_recent_symptoms_positions: {},
most_recent_treatments_positions: {}
)
end

factory :user do
sequence(:email) { |number| "user#{number}@example.com" }
password { "password123" }
password_confirmation { "password123" }
after(:create) { initialize_profile }
Comment on lines +30 to +45
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified the User factory to have the init_profile model from the User model and renamed it to initialize_profile because of the error below:

Done.
bin/rails aborted!
NameError: undefined local variable or method `init_profile' for #<FactoryBot::SyntaxRunner:0x00007eaac2e3c560> (NameError)

    after(:create) { init_profile }
                     ^^^^^^^^^^^^
Did you mean?  initialize
/app/spec/factories/users.rb:45:in `block (3 levels) in <top (required)>'
/app/db/seeds/development/users.seeds.rb:4:in `block in evaluate'
/app/db/seeds/development/users.seeds.rb:3:in `each'
/app/db/seeds/development/users.seeds.rb:3:in `evaluate'
Tasks: TOP => db:seed => db:seed:development => db:seed:development:users
(See full trace by running task with --trace)

end
end