Skip to content

Commit

Permalink
BASIRA #254 - Updating documents "number_fastenings" default value
Browse files Browse the repository at this point in the history
  • Loading branch information
dleadbetter committed Nov 27, 2024
1 parent 803fc29 commit 07b4fff
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
4 changes: 3 additions & 1 deletion client/src/pages/admin/Document.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,12 @@ const Document = (props: Props) => {
required={props.isRequired('number_fastenings')}
>
<Dropdown
defaultValue={0}
fluid
onChange={props.onTextInputChange.bind(this, 'number_fastenings')}
options={zeroToTenRangeOptionsList}
selection
value={props.item.number_fastenings || ''}
value={props.item.number_fastenings}
/>
</Form.Input>
<ValueListDropdown
Expand Down
15 changes: 15 additions & 0 deletions db/data/20241127155125_reset_documents_number_fastenings.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

class ResetDocumentsNumberFastenings < ActiveRecord::Migration[7.0]
def up
execute <<-SQL.squish
UPDATE documents
SET number_fastenings = 0
WHERE number_fastenings IS NULL;
SQL
end

def down
raise ActiveRecord::IrreversibleMigration
end
end
2 changes: 1 addition & 1 deletion db/data_schema.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
DataMigrate::Data.define(version: 20241127124509)
DataMigrate::Data.define(version: 20241127155125)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ChangeDocumentsNumberFasteningsDefaultValue < ActiveRecord::Migration[7.0]
def change
change_column :documents, :number_fastenings, :integer, null: false, default: 0
end
end
4 changes: 2 additions & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 2024_11_27_124609) do
ActiveRecord::Schema[7.0].define(version: 2024_11_27_155237) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_stat_statements"
enable_extension "plpgsql"
Expand Down Expand Up @@ -113,7 +113,7 @@
t.string "name"
t.string "notes"
t.integer "number_sewing_supports", default: 0, null: false
t.integer "number_fastenings"
t.integer "number_fastenings", default: 0, null: false
t.boolean "inscriptions_on_binding", default: false, null: false
t.text "inscription_text"
t.boolean "endband_present", default: false, null: false
Expand Down

0 comments on commit 07b4fff

Please sign in to comment.