-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
115 changed files
with
178,791 additions
and
26,741 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"recommendations": [ | ||
"ms-playwright.playwright" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
app/migrations/20241003213605-create_assistant_thread_table.cjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"use strict"; | ||
|
||
const sql_up = `create table if not exists public."AssistantThread" | ||
( | ||
assistant_thread_id text not null primary key, | ||
assistant_id text not null, | ||
created timestamp, | ||
last_updated timestamp | ||
); | ||
`; | ||
|
||
const sql_down = `drop table if exists public."AssistantThread";`; | ||
|
||
/** @type {import("sequelize-cli").Migration} */ | ||
module.exports = { | ||
async up(queryInterface, Sequelize) { | ||
await queryInterface.sequelize.query(sql_up); | ||
}, | ||
|
||
async down(queryInterface, Sequelize) { | ||
await queryInterface.sequelize.query(sql_down); | ||
}, | ||
}; |
37 changes: 37 additions & 0 deletions
37
app/migrations/20241003214418-create_assistant_messages_table.cjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"use strict"; | ||
|
||
const sql_up = ` | ||
BEGIN; | ||
create type role_enum as enum('user', 'assistant'); | ||
create table if not exists public."AssistantMessage" | ||
( | ||
assistant_message_id text not null primary key, | ||
thread_id text not null, | ||
role role_enum not null, | ||
timestamp timestamp not null, | ||
content text, | ||
created timestamp, | ||
last_updated timestamp, | ||
CONSTRAINT fk_thread | ||
FOREIGN KEY(thread_id) | ||
REFERENCES public."AssistantThread"(assistant_thread_id) | ||
ON DELETE CASCADE | ||
); | ||
CREATE INDEX idx_assistant_message_thread_id ON public."AssistantMessage" (thread_id); | ||
COMMIT; | ||
`; | ||
const sql_down = `drop table if exists public."AssistantMessages"; | ||
DROP TYPE IF EXISTS role_enum;`; | ||
|
||
/** @type {import("sequelize-cli").Migration} */ | ||
module.exports = { | ||
async up(queryInterface, Sequelize) { | ||
await queryInterface.sequelize.query(sql_up); | ||
}, | ||
|
||
async down(queryInterface, Sequelize) { | ||
await queryInterface.sequelize.query(sql_down); | ||
}, | ||
}; |
25 changes: 25 additions & 0 deletions
25
app/migrations/20241008124332-migrate-user-data-from-datasource-to-activityvalue.cjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
"use strict"; | ||
|
||
/** @type {import('sequelize-cli').Migration} */ | ||
module.exports = { | ||
async up(queryInterface, Sequelize) { | ||
await queryInterface.sequelize.query(` | ||
UPDATE "ActivityValue" av | ||
SET metadata = COALESCE(av.metadata, '{}'::jsonb) || jsonb_build_object( | ||
'sourceExplanation', dsi."notes", | ||
'dataQuality', dsi."data_quality" | ||
) | ||
FROM "DataSourceI18n" dsi | ||
WHERE av."datasource_id" = dsi."datasource_id" | ||
AND (dsi."notes" IS NOT NULL OR dsi."data_quality" IS NOT NULL); | ||
`); | ||
}, | ||
|
||
async down(queryInterface, Sequelize) { | ||
await queryInterface.sequelize.query(` | ||
UPDATE "ActivityValue" av | ||
SET metadata = av.metadata - 'sourceExplanation' - 'dataQuality' | ||
WHERE av.metadata ? 'sourceExplanation' OR av.metadata ? 'dataQuality'; | ||
`); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
"use strict"; | ||
const { DataTypes } = require("sequelize"); | ||
/** @type {import('sequelize-cli').Migration} */ | ||
module.exports = { | ||
async up(queryInterface, Sequelize) { | ||
await queryInterface.createTable("FormulaInput", { | ||
gas: { | ||
type: DataTypes.STRING, | ||
allowNull: false, | ||
}, | ||
parameter_code: { | ||
type: DataTypes.STRING, | ||
allowNull: false, | ||
}, | ||
parameter_name: { | ||
type: DataTypes.STRING, | ||
allowNull: false, | ||
}, | ||
methodology_name: { | ||
type: DataTypes.STRING, | ||
allowNull: false, | ||
}, | ||
methodology_id: { | ||
type: DataTypes.UUID, | ||
allowNull: true, | ||
references: { | ||
model: "Methodology", | ||
key: "methodology_id", | ||
}, | ||
field: "methodology_id", | ||
}, | ||
gpc_refno: { | ||
type: DataTypes.STRING, | ||
allowNull: false, | ||
}, | ||
year: { | ||
type: DataTypes.INTEGER, | ||
allowNull: true, | ||
}, | ||
formula_input_value: { | ||
type: DataTypes.FLOAT, | ||
allowNull: false, | ||
}, | ||
formula_input_units: { | ||
type: DataTypes.STRING, | ||
allowNull: false, | ||
}, | ||
formula_name: { | ||
type: DataTypes.STRING, | ||
allowNull: false, | ||
}, | ||
metadata: { | ||
type: DataTypes.JSONB, // PostgreSQL JSONB type | ||
allowNull: true, | ||
}, | ||
region: { | ||
type: DataTypes.STRING, | ||
allowNull: false, | ||
}, | ||
actor_id: { | ||
type: DataTypes.STRING, | ||
allowNull: false, | ||
}, | ||
datasource: { | ||
type: DataTypes.STRING, | ||
allowNull: false, | ||
}, | ||
rnk: { | ||
type: DataTypes.INTEGER, | ||
allowNull: false, | ||
}, | ||
formulainput_id: { | ||
type: DataTypes.UUID, | ||
allowNull: false, | ||
primaryKey: true, | ||
}, | ||
created_at: { | ||
type: DataTypes.DATE, | ||
allowNull: true, | ||
defaultValue: DataTypes.NOW, | ||
}, | ||
updated_at: { | ||
type: DataTypes.DATE, | ||
allowNull: true, | ||
defaultValue: DataTypes.NOW, | ||
}, | ||
}); | ||
}, | ||
|
||
async down(queryInterface, Sequelize) { | ||
await queryInterface.dropTable("FormulaInput"); | ||
}, | ||
}; |
42 changes: 42 additions & 0 deletions
42
app/migrations/20241011100332-formula-inputs-datasources.cjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
"use strict"; | ||
|
||
const { DataTypes } = require("sequelize"); | ||
/** @type {import('sequelize-cli').Migration} */ | ||
module.exports = { | ||
async up(queryInterface, Sequelize) { | ||
await queryInterface.createTable("DataSourceFormulaInput", { | ||
datasource_id: { | ||
type: DataTypes.UUID, | ||
allowNull: true, | ||
references: { | ||
model: "DataSourceI18n", | ||
key: "datasource_id", | ||
}, | ||
field: "datasource_id", | ||
}, | ||
formulainput_id: { | ||
type: DataTypes.UUID, | ||
allowNull: true, | ||
references: { | ||
model: "FormulaInput", | ||
key: "formulainput_id", | ||
}, | ||
field: "formulainput_id", | ||
}, | ||
created_at: { | ||
type: DataTypes.DATE, | ||
allowNull: true, | ||
defaultValue: DataTypes.NOW, | ||
}, | ||
updated_at: { | ||
type: DataTypes.DATE, | ||
allowNull: true, | ||
defaultValue: DataTypes.NOW, | ||
}, | ||
}); | ||
}, | ||
|
||
async down(queryInterface, Sequelize) { | ||
await queryInterface.dropTable("DatasourceFormulaInput"); | ||
}, | ||
}; |
Oops, something went wrong.