This commit is contained in:
parent
1c2d245f7c
commit
6e76293a94
33
apps/blakus-api/migrations/20250315105546_place_address.js
Normal file
33
apps/blakus-api/migrations/20250315105546_place_address.js
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/**
|
||||||
|
* @param { import("knex").Knex } knex
|
||||||
|
* @returns { Promise<void> }
|
||||||
|
*/
|
||||||
|
exports.up = function(knex) {
|
||||||
|
return knex.schema
|
||||||
|
.alterTable('places', function (table) {
|
||||||
|
table.string('country', 2);
|
||||||
|
table.string('county');
|
||||||
|
table.string('district');
|
||||||
|
table.string('city');
|
||||||
|
table.string('street');
|
||||||
|
table.string('house');
|
||||||
|
table.string('postalCode');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param { import("knex").Knex } knex
|
||||||
|
* @returns { Promise<void> }
|
||||||
|
*/
|
||||||
|
exports.down = function(knex) {
|
||||||
|
return knex.schema
|
||||||
|
.alterTable('places', function (table) {
|
||||||
|
table.dropColumn('country');
|
||||||
|
table.dropColumn('county');
|
||||||
|
table.dropColumn('district');
|
||||||
|
table.dropColumn('city');
|
||||||
|
table.dropColumn('street');
|
||||||
|
table.dropColumn('house');
|
||||||
|
table.dropColumn('postalCode')
|
||||||
|
});
|
||||||
|
};
|
||||||
@ -19,6 +19,13 @@ exports.seed = async function(knex) {
|
|||||||
return {
|
return {
|
||||||
name: faker.company.name(),
|
name: faker.company.name(),
|
||||||
coordinates: knex.raw('ST_SetSRID(ST_MakePoint(?, ?), 4326)', coords),
|
coordinates: knex.raw('ST_SetSRID(ST_MakePoint(?, ?), 4326)', coords),
|
||||||
|
country: 'LV',
|
||||||
|
county: faker.helpers.arrayElement(['Kurzemes', 'Latgales', 'Rīgas', 'Vidzemes', 'Zemgales']),
|
||||||
|
district: faker.location.state(),
|
||||||
|
city: faker.location.city(),
|
||||||
|
street: faker.location.street(),
|
||||||
|
house: faker.helpers.maybe(() => faker.person.lastName(), { probability: 0.1 }) || faker.location.buildingNumber(),
|
||||||
|
postalCode: faker.location.zipCode(),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user