diff --git a/db-migrations/migrations/20230912161927-add-labels-to-addresses.cjs b/db-migrations/migrations/20230912161927-add-labels-to-addresses.cjs new file mode 100644 index 00000000..f87d8b64 --- /dev/null +++ b/db-migrations/migrations/20230912161927-add-labels-to-addresses.cjs @@ -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') + } +} diff --git a/lib/api/address/schema.js b/lib/api/address/schema.js index be6268f6..fd42c312 100644 --- a/lib/api/address/schema.js +++ b/lib/api/address/schema.js @@ -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'] @@ -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(), diff --git a/lib/util/sequelize.js b/lib/util/sequelize.js index 36a9c2c1..5fa5aff4 100644 --- a/lib/util/sequelize.js +++ b/lib/util/sequelize.js @@ -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,