Skip to content

Commit

Permalink
Merge pull request #263 from BaseAdresseNationale/antoineludeau/add-c…
Browse files Browse the repository at this point in the history
…omplementary-labels-to-address-schema

Added labels field to address schema and its migration file
  • Loading branch information
antoineludeau authored Sep 26, 2023
2 parents 514c8fd + c5aaa10 commit 38dbfa5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict'

module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.addColumn('Addresses', 'labels', {
type: Sequelize.ARRAY(Sequelize.JSONB),
allowNull: true,
})
},

async down(queryInterface) {
await queryInterface.removeColumn('Addresses', 'labels')
}
}
3 changes: 2 additions & 1 deletion lib/api/address/schema.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {object, string, number, boolean, array, date} from 'yup'
import {banID, geometrySchema, cadastreSchema} from '../schema.js'
import {banID, geometrySchema, labelSchema, cadastreSchema} from '../schema.js'

const PositionTypes = ['entrance', 'building', 'staircase identifier', 'unit identifier', 'utility service', 'postal delivery', 'parcel', 'segment', 'other']

Expand All @@ -19,6 +19,7 @@ export const banAddressSchema = object({
districtID: banID.required(),
number: number().positive().integer().required(),
suffix: string().trim(),
labels: array().of(labelSchema).default(null).nullable(),
certified: boolean(),
positions: array().of(positionSchema).required(),
updateDate: date().required(),
Expand Down
4 changes: 4 additions & 0 deletions lib/util/sequelize.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ export const Address = sequelize.define('Address', {
type: DataTypes.STRING,
allowNull: true,
},
labels: {
type: DataTypes.ARRAY(DataTypes.JSONB),
allowNull: true,
},
certified: {
type: DataTypes.BOOLEAN,
allowNull: true,
Expand Down

0 comments on commit 38dbfa5

Please sign in to comment.