Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .sequelizerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const path = require('path');

module.exports = {
config: path.resolve('db', 'config.json'),
//'models-path': path.resolve('src/services/db', 'models'),
'seeders-path': path.resolve('db', 'seeders'),
'migrations-path': path.resolve('db', 'migrations'),
};
7 changes: 6 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,15 @@ WORKDIR /usr/src/app
COPY --from=build /usr/src/app/node_modules ./node_modules
COPY --from=build /usr/src/app/server ./server
COPY --from=build /usr/src/app/dist ./dist
COPY --from=build /usr/src/app/db ./db
COPY --from=build /usr/src/app/.sequelizerc ./

# COPY --from=build /usr/src/app/.env ./

# Expose the application port
EXPOSE 3000

VOLUME /usr/src/app/data

# Start the application
CMD [ "node", "server/entry.express" ]
CMD "/bin/bash -c 'node node_modules/sequelize-cli/lib/sequelize db:migrate --env production && node server/entry.express.js'"
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ OAUTH_CLIENT_ID
HF_TOKEN=X
```

Please note that if you define the `HF_TOKEN`, this variable will take priority over `OAUTH_CLIENT_ID`.
Please note that if you define the `OAUTH_CLIENT_ID`, this variable will take priority over `HF_TOKEN`.

Development mode uses [Vite's development server](https://vitejs.dev/). The `dev` command will server-side render (SSR) the output during development.

Expand Down Expand Up @@ -101,3 +101,19 @@ pnpm serve
```

Then visit [http://localhost:8080/](http://localhost:8080/)

### DB migrations

Before running a server, the database migrations must be up-to-date. The default `pnpm dev`, `pnpm test`, `pnpm preview`, and `pnpm server` commands already include this step. However, if you want to run migrations manually, you can use the following command:

```
pnpm migrate:up
```

If you want to rollback all the migrations, you can use the following command:

```
pnpm migrate:down
```

For more information, visit the official [Sequelize documentation on migrations](https://sequelize.org/docs/v6/other-topics/migrations/#running-migrations).
25 changes: 25 additions & 0 deletions db/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"development": {
"username": null,
"password": null,
"database": "dataground",
"dialect": "sqlite",
"storage": "data/development.db"
},

"test": {
"username": null,
"password": null,
"database": "dataground",
"dialect": "sqlite",
"storage": "data/test.db"
},

"production": {
"username": null,
"password": null,
"database": "dataground",
"dialect": "sqlite",
"storage": "data/production.db"
}
}
30 changes: 30 additions & 0 deletions db/migrations/20250312091036-create-datasets-table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module.exports = {
up: async (queryInterface, Sequelize) => {
return await queryInterface.createTable('datasets', {
id: {
type: Sequelize.DataTypes.UUID,
defaultValue: Sequelize.DataTypes.UUIDV4,
primaryKey: true,
},
name: {
type: Sequelize.DataTypes.STRING,
allowNull: false,
},
createdBy: {
type: Sequelize.DataTypes.STRING,
allowNull: false,
},
createdAt: {
allowNull: false,
type: Sequelize.DATE,
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE,
},
});
},
down: async (queryInterface, Sequelize) => {
return await queryInterface.dropTable('datasets');
},
};
63 changes: 63 additions & 0 deletions db/migrations/20250312092712-create-columns-table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up(queryInterface, Sequelize) {
/**
* Add altering commands here.
*
* Example:
* await queryInterface.createTable('users', { id: Sequelize.INTEGER });
*/
return await queryInterface.createTable('columns', {
id: {
type: Sequelize.DataTypes.UUID,
defaultValue: Sequelize.DataTypes.UUIDV4,
primaryKey: true,
},
name: {
type: Sequelize.DataTypes.STRING,
allowNull: false,
},
type: {
type: Sequelize.DataTypes.STRING,
allowNull: false,
},
kind: {
type: Sequelize.DataTypes.STRING,
allowNull: false,
},
visible: {
type: Sequelize.DataTypes.BOOLEAN,
allowNull: false,
defaultValue: true,
},
datasetId: {
type: Sequelize.DataTypes.UUID,
allowNull: false,
references: {
model: {
tableName: 'datasets',
},
key: 'id',
},
},
createdAt: {
allowNull: false,
type: Sequelize.DATE,
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE,
},
});
},

async down(queryInterface, Sequelize) {
/**
* Add reverting commands here.
*
* Example:
* await queryInterface.dropTable('users');
*/
return await queryInterface.dropTable('columns');
},
};
69 changes: 69 additions & 0 deletions db/migrations/20250312093117-create-processes-table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up(queryInterface, Sequelize) {
/**
* Add altering commands here.
*
* Example:
* await queryInterface.createTable('users', { id: Sequelize.INTEGER });
*/

return queryInterface.createTable('processes', {
id: {
type: Sequelize.DataTypes.UUID,
defaultValue: Sequelize.DataTypes.UUIDV4,
primaryKey: true,
},
modelName: {
type: Sequelize.DataTypes.STRING,
allowNull: false,
},
modelProvider: {
type: Sequelize.DataTypes.STRING,
allowNull: false,
},
prompt: {
type: Sequelize.DataTypes.STRING,
allowNull: false,
},
offset: {
type: Sequelize.DataTypes.INTEGER,
defaultValue: 0,
allowNull: false,
},
limit: {
type: Sequelize.DataTypes.INTEGER,
defaultValue: 10,
allowNull: false,
},
columnId: {
type: Sequelize.DataTypes.UUID,
allowNull: false,
references: {
model: {
tableName: 'columns',
},
key: 'id',
},
},
createdAt: {
allowNull: false,
type: Sequelize.DATE,
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE,
},
});
},

async down(queryInterface, Sequelize) {
/**
* Add reverting commands here.
*
* Example:
* await queryInterface.dropTable('users');
*/
return queryInterface.dropTable('processes');
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up(queryInterface, Sequelize) {
/**
* Add altering commands here.
*
* Example:
* await queryInterface.createTable('users', { id: Sequelize.INTEGER });
*/

await queryInterface.createTable(
'process_referred_columns',
{
processId: {
type: Sequelize.DataTypes.UUID,
allowNull: false,
references: {
model: {
tableName: 'processes',
},
key: 'id',
},
},
columnId: {
type: Sequelize.DataTypes.UUID,
allowNull: false,
references: {
model: {
tableName: 'columns',
},
key: 'id',
},
},
},
{
uniqueKeys: {
process_referred_columns_unique: {
fields: ['processId', 'columnId'],
},
},
},
);
},

async down(queryInterface, Sequelize) {
/**
* Add reverting commands here.
*
* Example:
* await queryInterface.dropTable('users');
*/
},
};
66 changes: 66 additions & 0 deletions db/migrations/20250312100503-create-cells-table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up(queryInterface, Sequelize) {
/**
* Add altering commands here.
*
* Example:
* await queryInterface.createTable('users', { id: Sequelize.INTEGER });
*/
return queryInterface.createTable('cells', {
id: {
type: Sequelize.DataTypes.UUID,
defaultValue: Sequelize.DataTypes.UUIDV4,
primaryKey: true,
},
idx: {
type: Sequelize.DataTypes.INTEGER,
allowNull: false,
},
value: {
type: Sequelize.DataTypes.STRING,
allowNull: true,
},
error: {
type: Sequelize.DataTypes.STRING,
allowNull: true,
},
validated: {
type: Sequelize.DataTypes.BOOLEAN,
defaultValue: false,
},
generating: {
type: Sequelize.DataTypes.BOOLEAN,
defaultValue: false,
},
columnId: {
type: Sequelize.DataTypes.UUID,
allowNull: false,
references: {
model: {
tableName: 'columns',
},
key: 'id',
},
},
createdAt: {
allowNull: false,
type: Sequelize.DATE,
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE,
},
});
},

async down(queryInterface, Sequelize) {
/**
* Add reverting commands here.
*
* Example:
* await queryInterface.dropTable('users');
*/
return queryInterface.dropTable('cells');
},
};
3 changes: 3 additions & 0 deletions db/migrations/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "commonjs"
}
Loading