Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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[5.1]
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[5.1]
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[5.1]
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[5.1]
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[5.1]
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[5.1]
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[5.1]
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[5.1]
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[5.1]
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[5.1]
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[5.1]
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[5.1]
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[5.1]
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[5.1]
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[5.1]
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[5.1]
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[5.1]
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[5.1]
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[5.1]
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[5.1]
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[5.1]
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[5.1]
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[5.1]
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[5.1]
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[5.1]
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[5.1]
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[5.1]
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[5.1]
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[5.1]
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[5.1]
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[5.1]
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[5.1]
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[5.1]
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
Copy Markdown
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
Copy Markdown
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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Finally got around to this. Here is the traceback with the above line not commented out:

== 20170817154145 CreatePositions: migrating ==================================
-- create_table(:positions)
bin/rails aborted!
StandardError: An error has occurred, this and all later migrations canceled: (StandardError)

you can't define an already defined column '{:precision=>10, :scale=>7}' on 'positions'.
/app/db/migrate/20170817154145_create_positions.rb:7:in `block in change'
/app/db/migrate/20170817154145_create_positions.rb:3:in `change'
/app/lib/tasks/app.rake:45:in `build_database'
/app/lib/tasks/app.rake:32:in `setup'
/app/lib/tasks/app.rake:4:in `block (2 levels) in <top (required)>'

Caused by:
ArgumentError: you can't define an already defined column '{:precision=>10, :scale=>7}' on 'positions'. (ArgumentError)

              raise ArgumentError, "you can't define an already defined column '#{name}' on '#{@name}'."
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/app/db/migrate/20170817154145_create_positions.rb:7:in `block in change'
/app/db/migrate/20170817154145_create_positions.rb:3:in `change'
/app/lib/tasks/app.rake:45: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:migrate
(See full trace by running task with --trace)

make: *** [Makefile:23: seed] Error 1

From what I can tell, it seems that the database for some reason thinks latitude and longtitude are the same field. If it helps, I am using the Docker setup via make build and make seed.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Resolved in 17756c8

Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

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

The longitude column is commented out but it's required by the Position model. The Position model uses self.longitude in the set_location_name callback (backend/app/models/position.rb line 12), and the schema.rb shows this column should exist (backend/db/schema.rb line 76). Commenting out this column will break the Position model functionality and cause database errors. Uncomment this line to match the schema definition.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Resolved in 17756c8

end
end
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddPositionReferenceToWeather < ActiveRecord::Migration[5.1]
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[5.1]
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[5.1]
class AddRejectedTypeToProfiles < ActiveRecord::Migration[7.1]
def change
add_column :profiles, :rejected_type, :string
end
Expand Down
2 changes: 1 addition & 1 deletion backend/lib/tasks/app.rake
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace :app do
Rake::Task["db:create"].invoke
Rake::Task["db:migrate"].invoke
end
Rake::Task["db:fixtures:load"].invoke
#Rake::Task["db:schema:load"].invoke
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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?

Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

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

This change is incorrect and alters the original functionality. The original code invoked db:fixtures:load, but this PR changed it to db:schema:load (which is now commented out). The comment in the PR description mentions issues with schema loading, but the original task was for loading fixtures, not schema. If fixtures loading is failing, that should be investigated and fixed separately. Either restore the original db:fixtures:load invocation or remove the line entirely if fixtures are not needed, rather than changing it to a different commented-out task.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Resolved in c103d87

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 }
Copy link
Copy Markdown
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)

Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

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

This initialize_profile method and after(:create) callback are unnecessary and will cause issues. The User model already has an after_create :init_profile callback (see backend/app/models/user.rb line 60) that creates the profile with the exact same attributes. This duplicate callback could cause errors or create duplicate profiles. Remove both the initialize_profile method definition and the after(:create) callback from this factory.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Resolved in 235a49a

end
end
Loading