Set PostgreSQL Row Level Security with Sequelize

Viewed 132

Hello we are setting up our models as in the following code.

export const Account = {
  init: (sequelize: Sequelize): ModelDefined<IAccount, any> => {
    const AccountModel = sequelize.define(
      'Account',
      {
        id: { type: DataTypes.BIGINT, autoIncrement: true, primaryKey: true },
        paper: { type: DataTypes.BOOLEAN, defaultValue: false },
        holder_id: { type: DataTypes.INTEGER },
        owner_id: { type: DataTypes.INTEGER },
        created_at: { type: DataTypes.DATE, allowNull: false },
        updated_at: { type: DataTypes.DATE, allowNull: false },
        current_facility_id: { type: DataTypes.INTEGER },
        current_unit_id: { type: DataTypes.INTEGER },
        preferred_contact_method: { type: DataTypes.INTEGER, defaultValue: 0 },
      },
      {
        tableName: 'accounts',
        createdAt: 'created_at',
        updatedAt: 'updated_at',
      }
    );
    // Associations
    const AlternateModel: ModelDefined<IAlternate, any> = Alternate.init(sequelize);
    AccountModel.hasMany(AlternateModel, { foreignKey: 'account_id' });

    return AccountModel;
  },
};

I cannot find any documentation on how to set RLS on a table via Sequelize in TypeScript.

ALTER TABLE accounts ENABLE ROW LEVEL SECURITY;
0 Answers
Related