Skip to content

Commit

Permalink
feat: add latest population table
Browse files Browse the repository at this point in the history
Signed-off-by: Evan Prodromou <evan@openearth.org>
  • Loading branch information
evanp committed Nov 26, 2024
1 parent dba810a commit ff97343
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions api/migrations/20241126144816-latest-population.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
'use strict';

var dbm;
var type;
var seed;

/**
* We receive the dbmigrate dependency from dbmigrate initially.
* This enables us to not have to rely on NODE_PATH.
*/
exports.setup = function (options, seedLink) {
dbm = options.dbmigrate;
type = dbm.dataType;
seed = seedLink;
};

exports.up = async (db) =>
db.createTable('LatestPopulation', {
columns: {
actor_id: {
type: 'string',
length: 255,
primaryKey: true,
foreignKey: {
name: "latest_population_actor_actor_id_fk",
table: "Actor",
rules: {
onDelete: 'CASCADE',
onUpdate: 'RESTRICT',
},
mapping: "actor_id",
},
},
year: { type: 'int' },
population: { type: 'bigint' },
created: { type: 'timestamp', notNull: true },
last_updated: { type: 'timestamp', notNull: true },
datasource_id: {
type: 'string',
length: 255,
notNull: true,
foreignKey: {
name: 'latest_population_datasource_datasource_id_fk',
table: 'DataSource',
rules: {
onDelete: 'CASCADE',
onUpdate: 'RESTRICT',
},
mapping: 'datasource_id',
},
}
},
})

exports.down = async (db) =>
db.dropTable('LatestPopulation')

exports._meta = {
"version": 1
};

0 comments on commit ff97343

Please sign in to comment.