Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export default {
- up: (queryInterface, Sequelize) => queryInterface.createTable('Pubkeys', {
- id: {
- allowNull: false,
- autoIncrement: true,
- primaryKey: true,
- type: Sequelize.INTEGER,
- },
- type: {
- type: Sequelize.STRING,
- },
- value: {
- type: Sequelize.STRING,
- },
- createdAt: {
- allowNull: false,
- type: Sequelize.DATE,
- },
- updatedAt: {
- allowNull: false,
- type: Sequelize.DATE,
- },
- }),
- down: queryInterface => queryInterface.dropTable('Pubkeys'),
- };
- export default {
- up: (queryInterface, Sequelize) => queryInterface.createTable('Validators', {
- id: {
- allowNull: false,
- autoIncrement: true,
- primaryKey: true,
- type: Sequelize.INTEGER,
- },
- address: {
- type: Sequelize.STRING,
- },
- pubkeyId: {
- type: Sequelize.INTEGER,
- references: {
- model: 'Pubkeys', // name of Target model
- key: 'id', // key in Target model that we're referencing
- },
- onUpdate: 'CASCADE',
- onDelete: 'SET NULL',
- },
- voting_power: {
- type: Sequelize.STRING,
- },
- proposer_priority: {
- type: Sequelize.STRING,
- },
- createdAt: {
- allowNull: false,
- type: Sequelize.DATE,
- },
- updatedAt: {
- allowNull: false,
- type: Sequelize.DATE,
- },
- }),
- down: queryInterface => queryInterface.dropTable('Validators'),
- };
- export default (sequelize, DataTypes) => {
- const Pubkey = sequelize.define('Pubkey', {
- type: DataTypes.STRING,
- value: DataTypes.STRING,
- }, {});
- Pubkey.associate = function (models) {
- Pubkey.hasMany(models.Validator, { as: 'validators' });
- };
- return Pubkey;
- };
- module.exports = (sequelize, DataTypes) => {
- const Validator = sequelize.define('Validator', {
- address: DataTypes.STRING,
- voting_power: DataTypes.STRING,
- proposer_priority: DataTypes.STRING,
- pubkeyId: {
- type: DataTypes.INTEGER(10),
- allowNull: false,
- references: {
- model: 'Pubkeys', // name of Target model
- key: 'id', // key in Target model that we're referencing
- },
- },
- }, {});
- Validator.associate = function (models) {
- Validator.belongsTo(models.Pubkey, { foreignKey: 'pubkeyId', as: 'pubkey' });
- };
- return Validator;
- };
Advertisement
Add Comment
Please, Sign In to add comment