-
Notifications
You must be signed in to change notification settings - Fork 77
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
1 parent
bb4aac6
commit 5f4597b
Showing
2 changed files
with
60 additions
and
60 deletions.
There are no files selected for viewing
69 changes: 34 additions & 35 deletions
69
src/modules/repository/implementation/sequelize/migrations/20240429083058-create-paranet.js
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 |
---|---|---|
@@ -1,37 +1,36 @@ | ||
'use strict'; | ||
/** @type {import('sequelize-cli').Migration} */ | ||
module.exports = { | ||
async up(queryInterface, Sequelize) { | ||
await queryInterface.createTable('Paranets', { | ||
id: { | ||
allowNull: false, | ||
autoIncrement: true, | ||
primaryKey: true, | ||
type: Sequelize.INTEGER | ||
}, | ||
name: { | ||
type: Sequelize.STRING | ||
}, | ||
description: { | ||
type: Sequelize.STRING | ||
}, | ||
paranetId: { | ||
type: Sequelize.STRING | ||
}, | ||
kaCount: { | ||
type: Sequelize.INTEGER | ||
}, | ||
createdAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE | ||
}, | ||
updatedAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE | ||
} | ||
}); | ||
}, | ||
async down(queryInterface, Sequelize) { | ||
await queryInterface.dropTable('Paranets'); | ||
} | ||
}; | ||
async up(queryInterface, Sequelize) { | ||
await queryInterface.createTable('Paranets', { | ||
id: { | ||
allowNull: false, | ||
autoIncrement: true, | ||
primaryKey: true, | ||
type: Sequelize.INTEGER, | ||
}, | ||
name: { | ||
type: Sequelize.STRING, | ||
}, | ||
description: { | ||
type: Sequelize.STRING, | ||
}, | ||
paranetId: { | ||
type: Sequelize.STRING, | ||
}, | ||
kaCount: { | ||
type: Sequelize.INTEGER, | ||
}, | ||
createdAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE, | ||
}, | ||
updatedAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE, | ||
}, | ||
}); | ||
}, | ||
async down(queryInterface) { | ||
await queryInterface.dropTable('Paranets'); | ||
}, | ||
}; |
51 changes: 26 additions & 25 deletions
51
src/modules/repository/implementation/sequelize/models/paranet.js
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 |
---|---|---|
@@ -1,26 +1,27 @@ | ||
'use strict'; | ||
const { | ||
Model | ||
} = require('sequelize'); | ||
module.exports = (sequelize, DataTypes) => { | ||
class Paranet extends Model { | ||
/** | ||
* Helper method for defining associations. | ||
* This method is not a part of Sequelize lifecycle. | ||
* The `models/index` file will call this method automatically. | ||
*/ | ||
static associate(models) { | ||
// define association here | ||
import { Model } from 'sequelize'; | ||
|
||
export default (sequelize, DataTypes) => { | ||
class Paranet extends Model { | ||
/** | ||
* Helper method for defining associations. | ||
* This method is not a part of Sequelize lifecycle. | ||
* The `models/index` file will call this method automatically. | ||
*/ | ||
static associate() { | ||
// define association here | ||
} | ||
} | ||
} | ||
Paranet.init({ | ||
name: DataTypes.STRING, | ||
description: DataTypes.STRING, | ||
paranetId: DataTypes.STRING, | ||
kaCount: DataTypes.INTEGER | ||
}, { | ||
sequelize, | ||
modelName: 'Paranet', | ||
}); | ||
return Paranet; | ||
}; | ||
Paranet.init( | ||
{ | ||
name: DataTypes.STRING, | ||
description: DataTypes.STRING, | ||
paranetId: DataTypes.STRING, | ||
kaCount: DataTypes.INTEGER, | ||
}, | ||
{ | ||
sequelize, | ||
modelName: 'Paranet', | ||
}, | ||
); | ||
return Paranet; | ||
}; |