
const { v4: uuid } = require("uuid");

module.exports = {
  /**
   * @param{import("sequelize").QueryInterface} queryInterface
   * @return {Promise<void>}
   */
  async up(queryInterface) {
    const createdAt = new Date();
    const updatedAt = new Date();

    /** @type {Map<string, string>} */
    const idMap = new Map();

    /**
     * @param {string} key
     * @return {string}
     */
    function getId(key) {
      if (idMap.has(key)) {
        return idMap.get(key);
      }
      const id = uuid();
      idMap.set(key, id);
      return id;
    }

    await queryInterface.bulkInsert("roles", [
      
      
      { id: getId("Administrator"), name: "Administrator", createdAt, updatedAt },
      
       
        { id: getId("User"), name: "User", createdAt, updatedAt },
      
      
      { id: getId("Public"), name: "Public", createdAt, updatedAt },
    ]);

    /**
     * @param {string} name
     */
    function createPermissions(name) {
      return [
        { id: getId(`CREATE_${name.toUpperCase()}`), createdAt, updatedAt, name: `CREATE_${name.toUpperCase()}` },
        { id: getId(`READ_${name.toUpperCase()}`), createdAt, updatedAt, name: `READ_${name.toUpperCase()}` },
        { id: getId(`UPDATE_${name.toUpperCase()}`), createdAt, updatedAt, name: `UPDATE_${name.toUpperCase()}` },
        { id: getId(`DELETE_${name.toUpperCase()}`), createdAt, updatedAt, name: `DELETE_${name.toUpperCase()}` }
      ];
    }

    const entities = [
      "users","roles","permissions","subscriptions","feature_flags","matters","matter_parties","files","file_extractions","assistant_threads","assistant_messages","ai_jobs","legal_templates","template_fields","generated_documents","document_versions","research_queries","legal_sources","research_results","citator_checks","mock_trials","mock_trial_roles","mock_trial_turns","transcription_jobs","medical_chronology_reports","medical_events","causation_analyses","audit_events",,
    ];
await queryInterface.bulkInsert("permissions", entities.flatMap(createPermissions));
await queryInterface.bulkInsert("permissions", [{ id: getId(`READ_API_DOCS`), createdAt, updatedAt, name: `READ_API_DOCS` }]);
await queryInterface.bulkInsert("permissions", [{ id: getId(`CREATE_SEARCH`), createdAt, updatedAt, name: `CREATE_SEARCH`}]);


await queryInterface.sequelize.query(`create table "rolesPermissionsPermissions"
(
"createdAt"           timestamp with time zone not null,
"updatedAt"           timestamp with time zone not null,
"roles_permissionsId" uuid                     not null,
"permissionId"        uuid                     not null,
primary key ("roles_permissionsId", "permissionId")
);`);


await queryInterface.bulkInsert("rolesPermissionsPermissions", [
    
    
      
      
           
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('CREATE_USERS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('READ_USERS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('UPDATE_USERS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('DELETE_USERS') },
          
    
  
    
    
    
    
      
      
           
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('CREATE_SUBSCRIPTIONS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('READ_SUBSCRIPTIONS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('UPDATE_SUBSCRIPTIONS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('DELETE_SUBSCRIPTIONS') },
          
    
  
    
    
      
      
           
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('CREATE_FEATURE_FLAGS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('READ_FEATURE_FLAGS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('UPDATE_FEATURE_FLAGS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('DELETE_FEATURE_FLAGS') },
          
    
  
    
    
      
      
           
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('CREATE_MATTERS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('READ_MATTERS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('UPDATE_MATTERS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('DELETE_MATTERS') },
          
    
  
    
    
      
      
           
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('CREATE_MATTER_PARTIES') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('READ_MATTER_PARTIES') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('UPDATE_MATTER_PARTIES') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('DELETE_MATTER_PARTIES') },
          
    
  
    
    
      
      
           
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('CREATE_FILES') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('READ_FILES') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('UPDATE_FILES') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('DELETE_FILES') },
          
    
  
    
    
      
      
           
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('CREATE_FILE_EXTRACTIONS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('READ_FILE_EXTRACTIONS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('UPDATE_FILE_EXTRACTIONS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('DELETE_FILE_EXTRACTIONS') },
          
    
  
    
    
      
      
           
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('CREATE_ASSISTANT_THREADS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('READ_ASSISTANT_THREADS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('UPDATE_ASSISTANT_THREADS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('DELETE_ASSISTANT_THREADS') },
          
    
  
    
    
      
      
           
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('CREATE_ASSISTANT_MESSAGES') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('READ_ASSISTANT_MESSAGES') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('UPDATE_ASSISTANT_MESSAGES') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('DELETE_ASSISTANT_MESSAGES') },
          
    
  
    
    
      
      
           
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('CREATE_AI_JOBS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('READ_AI_JOBS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('UPDATE_AI_JOBS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('DELETE_AI_JOBS') },
          
    
  
    
    
      
      
           
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('CREATE_LEGAL_TEMPLATES') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('READ_LEGAL_TEMPLATES') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('UPDATE_LEGAL_TEMPLATES') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('DELETE_LEGAL_TEMPLATES') },
          
    
  
    
    
      
      
           
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('CREATE_TEMPLATE_FIELDS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('READ_TEMPLATE_FIELDS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('UPDATE_TEMPLATE_FIELDS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('DELETE_TEMPLATE_FIELDS') },
          
    
  
    
    
      
      
           
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('CREATE_GENERATED_DOCUMENTS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('READ_GENERATED_DOCUMENTS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('UPDATE_GENERATED_DOCUMENTS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('DELETE_GENERATED_DOCUMENTS') },
          
    
  
    
    
      
      
           
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('CREATE_DOCUMENT_VERSIONS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('READ_DOCUMENT_VERSIONS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('UPDATE_DOCUMENT_VERSIONS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('DELETE_DOCUMENT_VERSIONS') },
          
    
  
    
    
      
      
           
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('CREATE_RESEARCH_QUERIES') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('READ_RESEARCH_QUERIES') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('UPDATE_RESEARCH_QUERIES') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('DELETE_RESEARCH_QUERIES') },
          
    
  
    
    
      
      
           
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('CREATE_LEGAL_SOURCES') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('READ_LEGAL_SOURCES') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('UPDATE_LEGAL_SOURCES') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('DELETE_LEGAL_SOURCES') },
          
    
  
    
    
      
      
           
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('CREATE_RESEARCH_RESULTS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('READ_RESEARCH_RESULTS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('UPDATE_RESEARCH_RESULTS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('DELETE_RESEARCH_RESULTS') },
          
    
  
    
    
      
      
           
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('CREATE_CITATOR_CHECKS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('READ_CITATOR_CHECKS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('UPDATE_CITATOR_CHECKS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('DELETE_CITATOR_CHECKS') },
          
    
  
    
    
      
      
           
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('CREATE_MOCK_TRIALS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('READ_MOCK_TRIALS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('UPDATE_MOCK_TRIALS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('DELETE_MOCK_TRIALS') },
          
    
  
    
    
      
      
           
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('CREATE_MOCK_TRIAL_ROLES') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('READ_MOCK_TRIAL_ROLES') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('UPDATE_MOCK_TRIAL_ROLES') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('DELETE_MOCK_TRIAL_ROLES') },
          
    
  
    
    
      
      
           
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('CREATE_MOCK_TRIAL_TURNS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('READ_MOCK_TRIAL_TURNS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('UPDATE_MOCK_TRIAL_TURNS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('DELETE_MOCK_TRIAL_TURNS') },
          
    
  
    
    
      
      
           
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('CREATE_TRANSCRIPTION_JOBS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('READ_TRANSCRIPTION_JOBS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('UPDATE_TRANSCRIPTION_JOBS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('DELETE_TRANSCRIPTION_JOBS') },
          
    
  
    
    
      
      
           
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('CREATE_MEDICAL_CHRONOLOGY_REPORTS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('READ_MEDICAL_CHRONOLOGY_REPORTS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('UPDATE_MEDICAL_CHRONOLOGY_REPORTS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('DELETE_MEDICAL_CHRONOLOGY_REPORTS') },
          
    
  
    
    
      
      
           
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('CREATE_MEDICAL_EVENTS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('READ_MEDICAL_EVENTS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('UPDATE_MEDICAL_EVENTS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('DELETE_MEDICAL_EVENTS') },
          
    
  
    
    
      
      
           
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('CREATE_CAUSATION_ANALYSES') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('READ_CAUSATION_ANALYSES') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('UPDATE_CAUSATION_ANALYSES') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('DELETE_CAUSATION_ANALYSES') },
          
    
  
    
    
      
      
           
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('CREATE_AUDIT_EVENTS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('READ_AUDIT_EVENTS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('UPDATE_AUDIT_EVENTS') },
              { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('DELETE_AUDIT_EVENTS') },
          
    
  
    
     
  
      
       
         { createdAt, updatedAt, roles_permissionsId: getId("User"), permissionId: getId('CREATE_SEARCH') },
      
      
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_USERS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_USERS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_USERS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_USERS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_ROLES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_ROLES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_ROLES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_ROLES') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_PERMISSIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_PERMISSIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_PERMISSIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_PERMISSIONS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_SUBSCRIPTIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_SUBSCRIPTIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_SUBSCRIPTIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_SUBSCRIPTIONS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_FEATURE_FLAGS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_FEATURE_FLAGS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_FEATURE_FLAGS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_FEATURE_FLAGS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_MATTERS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_MATTERS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_MATTERS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_MATTERS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_MATTER_PARTIES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_MATTER_PARTIES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_MATTER_PARTIES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_MATTER_PARTIES') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_FILES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_FILES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_FILES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_FILES') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_FILE_EXTRACTIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_FILE_EXTRACTIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_FILE_EXTRACTIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_FILE_EXTRACTIONS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_ASSISTANT_THREADS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_ASSISTANT_THREADS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_ASSISTANT_THREADS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_ASSISTANT_THREADS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_ASSISTANT_MESSAGES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_ASSISTANT_MESSAGES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_ASSISTANT_MESSAGES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_ASSISTANT_MESSAGES') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_AI_JOBS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_AI_JOBS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_AI_JOBS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_AI_JOBS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_LEGAL_TEMPLATES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_LEGAL_TEMPLATES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_LEGAL_TEMPLATES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_LEGAL_TEMPLATES') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_TEMPLATE_FIELDS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_TEMPLATE_FIELDS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_TEMPLATE_FIELDS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_TEMPLATE_FIELDS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_GENERATED_DOCUMENTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_GENERATED_DOCUMENTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_GENERATED_DOCUMENTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_GENERATED_DOCUMENTS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_DOCUMENT_VERSIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_DOCUMENT_VERSIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_DOCUMENT_VERSIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_DOCUMENT_VERSIONS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_RESEARCH_QUERIES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_RESEARCH_QUERIES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_RESEARCH_QUERIES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_RESEARCH_QUERIES') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_LEGAL_SOURCES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_LEGAL_SOURCES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_LEGAL_SOURCES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_LEGAL_SOURCES') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_RESEARCH_RESULTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_RESEARCH_RESULTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_RESEARCH_RESULTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_RESEARCH_RESULTS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_CITATOR_CHECKS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_CITATOR_CHECKS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_CITATOR_CHECKS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_CITATOR_CHECKS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_MOCK_TRIALS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_MOCK_TRIALS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_MOCK_TRIALS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_MOCK_TRIALS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_MOCK_TRIAL_ROLES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_MOCK_TRIAL_ROLES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_MOCK_TRIAL_ROLES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_MOCK_TRIAL_ROLES') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_MOCK_TRIAL_TURNS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_MOCK_TRIAL_TURNS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_MOCK_TRIAL_TURNS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_MOCK_TRIAL_TURNS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_TRANSCRIPTION_JOBS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_TRANSCRIPTION_JOBS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_TRANSCRIPTION_JOBS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_TRANSCRIPTION_JOBS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_MEDICAL_CHRONOLOGY_REPORTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_MEDICAL_CHRONOLOGY_REPORTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_MEDICAL_CHRONOLOGY_REPORTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_MEDICAL_CHRONOLOGY_REPORTS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_MEDICAL_EVENTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_MEDICAL_EVENTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_MEDICAL_EVENTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_MEDICAL_EVENTS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_CAUSATION_ANALYSES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_CAUSATION_ANALYSES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_CAUSATION_ANALYSES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_CAUSATION_ANALYSES') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_AUDIT_EVENTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_AUDIT_EVENTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_AUDIT_EVENTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_AUDIT_EVENTS') },
    
    
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_API_DOCS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_SEARCH') },
    ]);


  await queryInterface.sequelize.query(`UPDATE "users" SET "app_roleId"='${getId("SuperAdmin")}' WHERE "email"='super_admin@flatlogic.com'`);
  await queryInterface.sequelize.query(`UPDATE "users" SET "app_roleId"='${getId("Administrator")}' WHERE "email"='admin@flatlogic.com'`);
  
   
      
       
        await queryInterface.sequelize.query(`UPDATE "users" SET "app_roleId"='${getId("User")}' WHERE "email"='client@hello.com'`);
        await queryInterface.sequelize.query(`UPDATE "users" SET "app_roleId"='${getId("User")}' WHERE "email"='john@doe.com'`);
      
      

}
};

