From 61b24483a71d048b0c3b99b335d3071f5daaccdb Mon Sep 17 00:00:00 2001 From: Kevin McConnell Date: Tue, 15 Apr 2025 09:38:02 +0100 Subject: [PATCH 001/413] Deploy to new node Our production node has been replaced; `fizzy-app-101` is the new one. --- config/deploy.production.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/deploy.production.yml b/config/deploy.production.yml index 4359af231..38cc04500 100644 --- a/config/deploy.production.yml +++ b/config/deploy.production.yml @@ -1,10 +1,10 @@ servers: web: hosts: - - once-fizzy-101 + - fizzy-app-101 jobs: hosts: - - once-fizzy-101 + - fizzy-app-101 proxy: hosts: From 7e5f71fedd0eaf9631051b028d2042039a33d741 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 15 Apr 2025 15:17:30 +0200 Subject: [PATCH 002/413] We will only have one account record per account Not sure why this was added in the first place. --- ...250415131630_remove_accounts_name_index.rb | 5 + db/schema.rb | 3 +- db/schema_cache.yml | 352 +++++++++--------- 3 files changed, 174 insertions(+), 186 deletions(-) create mode 100644 db/migrate/20250415131630_remove_accounts_name_index.rb diff --git a/db/migrate/20250415131630_remove_accounts_name_index.rb b/db/migrate/20250415131630_remove_accounts_name_index.rb new file mode 100644 index 000000000..bb5921619 --- /dev/null +++ b/db/migrate/20250415131630_remove_accounts_name_index.rb @@ -0,0 +1,5 @@ +class RemoveAccountsNameIndex < ActiveRecord::Migration[8.1] + def change + remove_index :accounts, :name + end +end diff --git a/db/schema.rb b/db/schema.rb index 51aa255e4..b4fada365 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.1].define(version: 2025_04_12_170620) do +ActiveRecord::Schema[8.1].define(version: 2025_04_15_131630) do create_table "accesses", force: :cascade do |t| t.integer "collection_id", null: false t.datetime "created_at", null: false @@ -28,7 +28,6 @@ ActiveRecord::Schema[8.1].define(version: 2025_04_12_170620) do t.string "name", null: false t.datetime "updated_at", null: false t.index ["join_code"], name: "index_accounts_on_join_code", unique: true - t.index ["name"], name: "index_accounts_on_name", unique: true end create_table "action_text_markdowns", force: :cascade do |t| diff --git a/db/schema_cache.yml b/db/schema_cache.yml index 951138801..dbe786903 100644 --- a/db/schema_cache.yml +++ b/db/schema_cache.yml @@ -50,26 +50,6 @@ columns: default_function: collation: comment: - - &9 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column - auto_increment: - name: updated_at - cast_type: *3 - sql_type_metadata: *4 - 'null': false - default: - default_function: - collation: - comment: - - &30 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column - auto_increment: - name: user_id - cast_type: *1 - sql_type_metadata: *2 - 'null': false - default: - default_function: - collation: - comment: - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: involvement @@ -90,6 +70,26 @@ columns: default_function: collation: comment: + - &9 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + auto_increment: + name: updated_at + cast_type: *3 + sql_type_metadata: *4 + 'null': false + default: + default_function: + collation: + comment: + - &30 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + auto_increment: + name: user_id + cast_type: *1 + sql_type_metadata: *2 + 'null': false + default: + default_function: + collation: + comment: accounts: - *5 - *6 @@ -443,6 +443,16 @@ columns: default_function: collation: comment: + - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + auto_increment: + name: last_active_at + cast_type: *3 + sql_type_metadata: *4 + 'null': false + default: + default_function: + collation: + comment: - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: stage_id @@ -474,18 +484,9 @@ columns: collation: comment: - *9 - - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column - auto_increment: - name: last_active_at - cast_type: *3 - sql_type_metadata: *4 - 'null': false - default: - default_function: - collation: - comment: closure_reasons: - *5 + - *6 - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: label @@ -496,12 +497,21 @@ columns: default_function: collation: comment: - - *6 - *9 closures: - *5 - *21 - *6 + - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + auto_increment: + name: reason + cast_type: *7 + sql_type_metadata: *8 + 'null': false + default: + default_function: + collation: + comment: - *9 - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: @@ -513,16 +523,6 @@ columns: default_function: collation: comment: - - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column - auto_increment: - name: reason - cast_type: *7 - sql_type_metadata: *8 - 'null': false - default: - default_function: - collation: - comment: collections: - *5 - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column @@ -906,6 +906,16 @@ columns: comment: workflow_stages: - *5 + - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + auto_increment: + name: color + cast_type: *7 + sql_type_metadata: *8 + 'null': true + default: + default_function: + collation: + comment: - *6 - *10 - *9 @@ -919,16 +929,6 @@ columns: default_function: collation: comment: - - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column - auto_increment: - name: color - cast_type: *7 - sql_type_metadata: *8 - 'null': true - default: - default_function: - collation: - comment: workflows: - *5 - *6 @@ -1012,10 +1012,9 @@ indexes: accesses: - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition table: accesses - name: index_accesses_on_collection_id_and_user_id - unique: true + name: index_accesses_on_user_id + unique: false columns: - - collection_id - user_id lengths: {} orders: {} @@ -1045,9 +1044,10 @@ indexes: valid: true - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition table: accesses - name: index_accesses_on_user_id - unique: false + name: index_accesses_on_collection_id_and_user_id + unique: true columns: + - collection_id - user_id lengths: {} orders: {} @@ -1060,22 +1060,6 @@ indexes: comment: valid: true accounts: - - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition - table: accounts - name: index_accounts_on_name - unique: true - columns: - - name - lengths: {} - orders: {} - opclasses: {} - where: - type: - using: - include: - nulls_not_distinct: - comment: - valid: true - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition table: accounts name: index_accounts_on_join_code @@ -1267,10 +1251,9 @@ indexes: assignments: - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition table: assignments - name: index_assignments_on_assignee_id_and_card_id - unique: true + name: index_assignments_on_card_id + unique: false columns: - - assignee_id - card_id lengths: {} orders: {} @@ -1284,9 +1267,10 @@ indexes: valid: true - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition table: assignments - name: index_assignments_on_card_id - unique: false + name: index_assignments_on_assignee_id_and_card_id + unique: true columns: + - assignee_id - card_id lengths: {} orders: {} @@ -1333,38 +1317,6 @@ indexes: comment: valid: true cards: - - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition - table: cards - name: index_cards_on_collection_id - unique: false - columns: - - collection_id - lengths: {} - orders: {} - opclasses: {} - where: - type: - using: - include: - nulls_not_distinct: - comment: - valid: true - - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition - table: cards - name: index_cards_on_activity_score_order - unique: false - columns: - - activity_score_order - lengths: {} - orders: {} - opclasses: {} - where: - type: - using: - include: - nulls_not_distinct: - comment: - valid: true - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition table: cards name: index_cards_on_stage_id @@ -1398,15 +1350,46 @@ indexes: nulls_not_distinct: comment: valid: true + - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition + table: cards + name: index_cards_on_collection_id + unique: false + columns: + - collection_id + lengths: {} + orders: {} + opclasses: {} + where: + type: + using: + include: + nulls_not_distinct: + comment: + valid: true + - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition + table: cards + name: index_cards_on_activity_score_order + unique: false + columns: + - activity_score_order + lengths: {} + orders: {} + opclasses: {} + where: + type: + using: + include: + nulls_not_distinct: + comment: + valid: true closure_reasons: [] closures: - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition table: closures - name: index_closures_on_card_id_and_created_at + name: index_closures_on_user_id unique: false columns: - - card_id - - created_at + - user_id lengths: {} orders: {} opclasses: {} @@ -1435,10 +1418,11 @@ indexes: valid: true - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition table: closures - name: index_closures_on_user_id + name: index_closures_on_card_id_and_created_at unique: false columns: - - user_id + - card_id + - created_at lengths: {} orders: {} opclasses: {} @@ -1450,22 +1434,6 @@ indexes: comment: valid: true collections: - - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition - table: collections - name: index_collections_on_creator_id - unique: false - columns: - - creator_id - lengths: {} - orders: {} - opclasses: {} - where: - type: - using: - include: - nulls_not_distinct: - comment: - valid: true - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition table: collections name: index_collections_on_workflow_id @@ -1482,13 +1450,29 @@ indexes: nulls_not_distinct: comment: valid: true + - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition + table: collections + name: index_collections_on_creator_id + unique: false + columns: + - creator_id + lengths: {} + orders: {} + opclasses: {} + where: + type: + using: + include: + nulls_not_distinct: + comment: + valid: true collections_filters: - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition table: collections_filters - name: index_collections_filters_on_collection_id + name: index_collections_filters_on_filter_id unique: false columns: - - collection_id + - filter_id lengths: {} orders: {} opclasses: {} @@ -1501,10 +1485,10 @@ indexes: valid: true - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition table: collections_filters - name: index_collections_filters_on_filter_id + name: index_collections_filters_on_collection_id unique: false columns: - - filter_id + - collection_id lengths: {} orders: {} opclasses: {} @@ -1551,22 +1535,6 @@ indexes: valid: true event_summaries: [] events: - - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition - table: events - name: index_events_on_card_id - unique: false - columns: - - card_id - lengths: {} - orders: {} - opclasses: {} - where: - type: - using: - include: - nulls_not_distinct: - comment: - valid: true - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition table: events name: index_events_on_summary_id_and_action @@ -1600,6 +1568,22 @@ indexes: nulls_not_distinct: comment: valid: true + - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition + table: events + name: index_events_on_card_id + unique: false + columns: + - card_id + lengths: {} + orders: {} + opclasses: {} + where: + type: + using: + include: + nulls_not_distinct: + comment: + valid: true filters: - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition table: filters @@ -1685,22 +1669,6 @@ indexes: comment: valid: true messages: - - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition - table: messages - name: index_messages_on_card_id - unique: false - columns: - - card_id - lengths: {} - orders: {} - opclasses: {} - where: - type: - using: - include: - nulls_not_distinct: - comment: - valid: true - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition table: messages name: index_messages_on_messageable @@ -1718,10 +1686,9 @@ indexes: nulls_not_distinct: comment: valid: true - notifications: - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition - table: notifications - name: index_notifications_on_card_id + table: messages + name: index_messages_on_card_id unique: false columns: - card_id @@ -1735,6 +1702,7 @@ indexes: nulls_not_distinct: comment: valid: true + notifications: - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition table: notifications name: index_notifications_on_user_id @@ -1804,13 +1772,28 @@ indexes: nulls_not_distinct: comment: valid: true + - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition + table: notifications + name: index_notifications_on_card_id + unique: false + columns: + - card_id + lengths: {} + orders: {} + opclasses: {} + where: + type: + using: + include: + nulls_not_distinct: + comment: + valid: true pins: - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition table: pins - name: index_pins_on_card_id_and_user_id - unique: true + name: index_pins_on_user_id + unique: false columns: - - card_id - user_id lengths: {} orders: {} @@ -1840,9 +1823,10 @@ indexes: valid: true - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition table: pins - name: index_pins_on_user_id - unique: false + name: index_pins_on_card_id_and_user_id + unique: true columns: + - card_id - user_id lengths: {} orders: {} @@ -1908,10 +1892,9 @@ indexes: taggings: - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition table: taggings - name: index_taggings_on_card_id_and_tag_id - unique: true + name: index_taggings_on_tag_id + unique: false columns: - - card_id - tag_id lengths: {} orders: {} @@ -1925,9 +1908,10 @@ indexes: valid: true - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition table: taggings - name: index_taggings_on_tag_id - unique: false + name: index_taggings_on_card_id_and_tag_id + unique: true columns: + - card_id - tag_id lengths: {} orders: {} @@ -1976,10 +1960,10 @@ indexes: watches: - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition table: watches - name: index_watches_on_card_id + name: index_watches_on_user_id unique: false columns: - - card_id + - user_id lengths: {} orders: {} opclasses: {} @@ -1992,10 +1976,10 @@ indexes: valid: true - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition table: watches - name: index_watches_on_user_id + name: index_watches_on_card_id unique: false columns: - - user_id + - card_id lengths: {} orders: {} opclasses: {} @@ -2024,4 +2008,4 @@ indexes: comment: valid: true workflows: [] -version: 20250412170620 +version: 20250415131630 From 2ace519d9119d42434aed27f6592c12c87f623ec Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 15 Apr 2025 15:35:10 +0200 Subject: [PATCH 003/413] There is only one account, so just check join code directly --- app/controllers/users_controller.rb | 6 +++--- app/views/users/new.html.erb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 4069e5aaa..39ce73313 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2,7 +2,7 @@ class UsersController < ApplicationController require_unauthenticated_access only: %i[ new create ] before_action :set_user, only: %i[ show edit update destroy ] - before_action :set_account_from_join_code, only: %i[ new create ] + before_action :ensure_join_code_is_valid, only: %i[ new create ] before_action :ensure_permission_to_administer_user, only: %i[ update destroy ] def index @@ -36,8 +36,8 @@ class UsersController < ApplicationController end private - def set_account_from_join_code - @account = Account.find_by_join_code!(params[:join_code]) + def ensure_join_code_is_valid + head :forbidden unless Account.sole.join_code == params[:join_code] end def set_user diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb index fa9ca8312..40f078bdc 100644 --- a/app/views/users/new.html.erb +++ b/app/views/users/new.html.erb @@ -11,7 +11,7 @@

Fizzy

- <%= form_with model: @user, url: join_path(@account.join_code), class: "flex flex-column gap" do |form| %> + <%= form_with model: @user, url: join_path(params[:join_code]), class: "flex flex-column gap" do |form| %>