
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("SuperAdmin"), name: "Super Administrator", createdAt, updatedAt },
      
      
      { id: getId("Administrator"), name: "Administrator", createdAt, updatedAt },
      
      
        
          { id: getId("WorkspaceOwner"), name: "Workspace Owner", createdAt, updatedAt },
        
          { id: getId("WorkspaceManager"), name: "Workspace Manager", createdAt, updatedAt },
        
          { id: getId("ContentEngineer"), name: "Content Engineer", createdAt, updatedAt },
        
          { id: getId("StudyCoach"), name: "Study Coach", createdAt, updatedAt },
        
          { id: getId("Learner"), name: "Learner", 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","organizations","workspaces","workspace_memberships","subjects","topics","pages","blocks","databases","database_entries","sources","source_chunks","ai_jobs","concept_maps","study_guides","flashcard_decks","flashcards","spaced_repetition_states","study_sessions","review_events","quizzes","quiz_questions","quiz_attempts","tutor_conversations","tutor_messages","study_plans","study_plan_items","dashboard_snapshots",,
    ];
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.bulkUpdate('roles', { globalAccess: true }, { id: getId('SuperAdmin') });


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("WorkspaceOwner"), permissionId: getId('CREATE_USERS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                  
                    
                  
                    
                  
                  
             
          
    
  
    
    
    
    
      
      
          
                
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceOwner"), permissionId: getId('CREATE_WORKSPACES') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceManager"), permissionId: getId('CREATE_WORKSPACES') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                  
                    
                  
                    
                  
                  
             
          
    
  
    
    
      
      
          
                
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceOwner"), permissionId: getId('CREATE_WORKSPACE_MEMBERSHIPS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceManager"), permissionId: getId('CREATE_WORKSPACE_MEMBERSHIPS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                  
                    
                  
                    
                  
                  
             
          
    
  
    
    
      
      
          
                
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceOwner"), permissionId: getId('CREATE_SUBJECTS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceManager"), permissionId: getId('CREATE_SUBJECTS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ContentEngineer"), permissionId: getId('CREATE_SUBJECTS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                  
                    
                  
                    
                  
                  
             
          
    
  
    
    
      
      
          
                
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceOwner"), permissionId: getId('CREATE_TOPICS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceManager"), permissionId: getId('CREATE_TOPICS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ContentEngineer"), permissionId: getId('CREATE_TOPICS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                  
                    
                  
                    
                  
                  
             
          
    
  
    
    
      
      
          
                
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceOwner"), permissionId: getId('CREATE_PAGES') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceManager"), permissionId: getId('CREATE_PAGES') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ContentEngineer"), permissionId: getId('CREATE_PAGES') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                  
                    
                  
                    
                  
                  
             
          
    
  
    
    
      
      
          
                
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceOwner"), permissionId: getId('CREATE_BLOCKS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceManager"), permissionId: getId('CREATE_BLOCKS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ContentEngineer"), permissionId: getId('CREATE_BLOCKS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                  
                    
                  
                    
                  
                  
             
          
    
  
    
    
      
      
          
                
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceOwner"), permissionId: getId('CREATE_DATABASES') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceManager"), permissionId: getId('CREATE_DATABASES') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ContentEngineer"), permissionId: getId('CREATE_DATABASES') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                  
                    
                  
                    
                  
                  
             
          
    
  
    
    
      
      
          
                
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceOwner"), permissionId: getId('CREATE_DATABASE_ENTRIES') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceManager"), permissionId: getId('CREATE_DATABASE_ENTRIES') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ContentEngineer"), permissionId: getId('CREATE_DATABASE_ENTRIES') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                  
                    
                  
                    
                  
                  
             
          
    
  
    
    
      
      
          
                
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceOwner"), permissionId: getId('CREATE_SOURCES') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceManager"), permissionId: getId('CREATE_SOURCES') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ContentEngineer"), permissionId: getId('CREATE_SOURCES') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Learner"), permissionId: getId('CREATE_SOURCES') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
             
          
    
  
    
    
      
      
          
                
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceOwner"), permissionId: getId('CREATE_SOURCE_CHUNKS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceManager"), permissionId: getId('READ_SOURCE_CHUNKS') },
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ContentEngineer"), permissionId: getId('CREATE_SOURCE_CHUNKS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                  
                    
                  
                    
                  
                  
             
          
    
  
    
    
      
      
          
                
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceOwner"), permissionId: getId('CREATE_AI_JOBS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceManager"), permissionId: getId('CREATE_AI_JOBS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ContentEngineer"), permissionId: getId('CREATE_AI_JOBS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Learner"), permissionId: getId('CREATE_AI_JOBS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
             
          
    
  
    
    
      
      
          
                
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceOwner"), permissionId: getId('CREATE_CONCEPT_MAPS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceManager"), permissionId: getId('CREATE_CONCEPT_MAPS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ContentEngineer"), permissionId: getId('CREATE_CONCEPT_MAPS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                  
                    
                  
                    
                  
                  
             
          
    
  
    
    
      
      
          
                
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceOwner"), permissionId: getId('CREATE_STUDY_GUIDES') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceManager"), permissionId: getId('CREATE_STUDY_GUIDES') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ContentEngineer"), permissionId: getId('CREATE_STUDY_GUIDES') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                  
                    
                  
                    
                  
                  
             
          
    
  
    
    
      
      
          
                
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceOwner"), permissionId: getId('CREATE_FLASHCARD_DECKS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceManager"), permissionId: getId('CREATE_FLASHCARD_DECKS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ContentEngineer"), permissionId: getId('CREATE_FLASHCARD_DECKS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("StudyCoach"), permissionId: getId('CREATE_FLASHCARD_DECKS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Learner"), permissionId: getId('CREATE_FLASHCARD_DECKS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
             
          
    
  
    
    
      
      
          
                
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceOwner"), permissionId: getId('CREATE_FLASHCARDS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceManager"), permissionId: getId('CREATE_FLASHCARDS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ContentEngineer"), permissionId: getId('CREATE_FLASHCARDS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("StudyCoach"), permissionId: getId('CREATE_FLASHCARDS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Learner"), permissionId: getId('CREATE_FLASHCARDS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
             
          
    
  
    
    
      
      
          
                
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceOwner"), permissionId: getId('CREATE_SPACED_REPETITION_STATES') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceManager"), permissionId: getId('CREATE_SPACED_REPETITION_STATES') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("StudyCoach"), permissionId: getId('CREATE_SPACED_REPETITION_STATES') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Learner"), permissionId: getId('CREATE_SPACED_REPETITION_STATES') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
             
          
    
  
    
    
      
      
          
                
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceOwner"), permissionId: getId('CREATE_STUDY_SESSIONS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceManager"), permissionId: getId('CREATE_STUDY_SESSIONS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ContentEngineer"), permissionId: getId('CREATE_STUDY_SESSIONS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("StudyCoach"), permissionId: getId('CREATE_STUDY_SESSIONS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Learner"), permissionId: getId('CREATE_STUDY_SESSIONS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
             
          
    
  
    
    
      
      
          
                
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceOwner"), permissionId: getId('CREATE_REVIEW_EVENTS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceManager"), permissionId: getId('CREATE_REVIEW_EVENTS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("StudyCoach"), permissionId: getId('CREATE_REVIEW_EVENTS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Learner"), permissionId: getId('CREATE_REVIEW_EVENTS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
             
          
    
  
    
    
      
      
          
                
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceOwner"), permissionId: getId('CREATE_QUIZZES') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceManager"), permissionId: getId('CREATE_QUIZZES') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ContentEngineer"), permissionId: getId('CREATE_QUIZZES') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("StudyCoach"), permissionId: getId('CREATE_QUIZZES') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Learner"), permissionId: getId('CREATE_QUIZZES') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
             
          
    
  
    
    
      
      
          
                
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceOwner"), permissionId: getId('CREATE_QUIZ_QUESTIONS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceManager"), permissionId: getId('CREATE_QUIZ_QUESTIONS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ContentEngineer"), permissionId: getId('CREATE_QUIZ_QUESTIONS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("StudyCoach"), permissionId: getId('CREATE_QUIZ_QUESTIONS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                  
                    
                  
                    
                  
                  
             
          
    
  
    
    
      
      
          
                
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceOwner"), permissionId: getId('CREATE_QUIZ_ATTEMPTS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceManager"), permissionId: getId('CREATE_QUIZ_ATTEMPTS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ContentEngineer"), permissionId: getId('CREATE_QUIZ_ATTEMPTS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("StudyCoach"), permissionId: getId('CREATE_QUIZ_ATTEMPTS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Learner"), permissionId: getId('CREATE_QUIZ_ATTEMPTS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
             
          
    
  
    
    
      
      
          
                
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceOwner"), permissionId: getId('CREATE_TUTOR_CONVERSATIONS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceManager"), permissionId: getId('CREATE_TUTOR_CONVERSATIONS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ContentEngineer"), permissionId: getId('CREATE_TUTOR_CONVERSATIONS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("StudyCoach"), permissionId: getId('CREATE_TUTOR_CONVERSATIONS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Learner"), permissionId: getId('CREATE_TUTOR_CONVERSATIONS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
             
          
    
  
    
    
      
      
          
                
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceOwner"), permissionId: getId('CREATE_TUTOR_MESSAGES') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceManager"), permissionId: getId('CREATE_TUTOR_MESSAGES') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ContentEngineer"), permissionId: getId('CREATE_TUTOR_MESSAGES') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("StudyCoach"), permissionId: getId('CREATE_TUTOR_MESSAGES') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Learner"), permissionId: getId('CREATE_TUTOR_MESSAGES') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
             
          
    
  
    
    
      
      
          
                
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceOwner"), permissionId: getId('CREATE_STUDY_PLANS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceManager"), permissionId: getId('CREATE_STUDY_PLANS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ContentEngineer"), permissionId: getId('CREATE_STUDY_PLANS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("StudyCoach"), permissionId: getId('CREATE_STUDY_PLANS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Learner"), permissionId: getId('CREATE_STUDY_PLANS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
             
          
    
  
    
    
      
      
          
                
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceOwner"), permissionId: getId('CREATE_STUDY_PLAN_ITEMS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceManager"), permissionId: getId('CREATE_STUDY_PLAN_ITEMS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ContentEngineer"), permissionId: getId('CREATE_STUDY_PLAN_ITEMS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("StudyCoach"), permissionId: getId('CREATE_STUDY_PLAN_ITEMS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Learner"), permissionId: getId('CREATE_STUDY_PLAN_ITEMS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
             
          
    
  
    
    
      
      
          
                
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceOwner"), permissionId: getId('CREATE_DASHBOARD_SNAPSHOTS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceManager"), permissionId: getId('CREATE_DASHBOARD_SNAPSHOTS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("StudyCoach"), permissionId: getId('CREATE_DASHBOARD_SNAPSHOTS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Learner"), permissionId: getId('CREATE_DASHBOARD_SNAPSHOTS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
             
          
    
  
    
     
  
      
      
        
            { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceOwner"), permissionId: getId('CREATE_SEARCH') },
        
            { createdAt, updatedAt, roles_permissionsId: getId("WorkspaceManager"), permissionId: getId('CREATE_SEARCH') },
        
            { createdAt, updatedAt, roles_permissionsId: getId("ContentEngineer"), permissionId: getId('CREATE_SEARCH') },
        
            { createdAt, updatedAt, roles_permissionsId: getId("StudyCoach"), permissionId: getId('CREATE_SEARCH') },
        
            { createdAt, updatedAt, roles_permissionsId: getId("Learner"), 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_WORKSPACES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_WORKSPACES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_WORKSPACES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_WORKSPACES') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_WORKSPACE_MEMBERSHIPS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_WORKSPACE_MEMBERSHIPS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_WORKSPACE_MEMBERSHIPS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_WORKSPACE_MEMBERSHIPS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_SUBJECTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_SUBJECTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_SUBJECTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_SUBJECTS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_TOPICS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_TOPICS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_TOPICS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_TOPICS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_PAGES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_PAGES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_PAGES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_PAGES') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_BLOCKS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_BLOCKS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_BLOCKS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_BLOCKS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_DATABASES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_DATABASES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_DATABASES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_DATABASES') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_DATABASE_ENTRIES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_DATABASE_ENTRIES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_DATABASE_ENTRIES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_DATABASE_ENTRIES') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_SOURCES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_SOURCES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_SOURCES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_SOURCES') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_SOURCE_CHUNKS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_SOURCE_CHUNKS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_SOURCE_CHUNKS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_SOURCE_CHUNKS') },
    
    { 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_CONCEPT_MAPS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_CONCEPT_MAPS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_CONCEPT_MAPS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_CONCEPT_MAPS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_STUDY_GUIDES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_STUDY_GUIDES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_STUDY_GUIDES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_STUDY_GUIDES') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_FLASHCARD_DECKS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_FLASHCARD_DECKS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_FLASHCARD_DECKS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_FLASHCARD_DECKS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_FLASHCARDS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_FLASHCARDS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_FLASHCARDS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_FLASHCARDS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_SPACED_REPETITION_STATES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_SPACED_REPETITION_STATES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_SPACED_REPETITION_STATES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_SPACED_REPETITION_STATES') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_STUDY_SESSIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_STUDY_SESSIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_STUDY_SESSIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_STUDY_SESSIONS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_REVIEW_EVENTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_REVIEW_EVENTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_REVIEW_EVENTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_REVIEW_EVENTS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_QUIZZES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_QUIZZES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_QUIZZES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_QUIZZES') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_QUIZ_QUESTIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_QUIZ_QUESTIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_QUIZ_QUESTIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_QUIZ_QUESTIONS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_QUIZ_ATTEMPTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_QUIZ_ATTEMPTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_QUIZ_ATTEMPTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_QUIZ_ATTEMPTS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_TUTOR_CONVERSATIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_TUTOR_CONVERSATIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_TUTOR_CONVERSATIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_TUTOR_CONVERSATIONS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_TUTOR_MESSAGES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_TUTOR_MESSAGES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_TUTOR_MESSAGES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_TUTOR_MESSAGES') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_STUDY_PLANS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_STUDY_PLANS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_STUDY_PLANS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_STUDY_PLANS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_STUDY_PLAN_ITEMS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_STUDY_PLAN_ITEMS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_STUDY_PLAN_ITEMS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_STUDY_PLAN_ITEMS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_DASHBOARD_SNAPSHOTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_DASHBOARD_SNAPSHOTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_DASHBOARD_SNAPSHOTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_DASHBOARD_SNAPSHOTS') },
    
    
    
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('CREATE_USERS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_USERS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('UPDATE_USERS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('DELETE_USERS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('CREATE_ROLES') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_ROLES') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('UPDATE_ROLES') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('DELETE_ROLES') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('CREATE_PERMISSIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_PERMISSIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('UPDATE_PERMISSIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('DELETE_PERMISSIONS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('CREATE_ORGANIZATIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_ORGANIZATIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('UPDATE_ORGANIZATIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('DELETE_ORGANIZATIONS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('CREATE_WORKSPACES') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_WORKSPACES') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('UPDATE_WORKSPACES') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('DELETE_WORKSPACES') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('CREATE_WORKSPACE_MEMBERSHIPS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_WORKSPACE_MEMBERSHIPS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('UPDATE_WORKSPACE_MEMBERSHIPS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('DELETE_WORKSPACE_MEMBERSHIPS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('CREATE_SUBJECTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_SUBJECTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('UPDATE_SUBJECTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('DELETE_SUBJECTS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('CREATE_TOPICS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_TOPICS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('UPDATE_TOPICS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('DELETE_TOPICS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('CREATE_PAGES') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_PAGES') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('UPDATE_PAGES') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('DELETE_PAGES') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('CREATE_BLOCKS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_BLOCKS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('UPDATE_BLOCKS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('DELETE_BLOCKS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('CREATE_DATABASES') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_DATABASES') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('UPDATE_DATABASES') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('DELETE_DATABASES') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('CREATE_DATABASE_ENTRIES') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_DATABASE_ENTRIES') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('UPDATE_DATABASE_ENTRIES') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('DELETE_DATABASE_ENTRIES') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('CREATE_SOURCES') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_SOURCES') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('UPDATE_SOURCES') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('DELETE_SOURCES') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('CREATE_SOURCE_CHUNKS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_SOURCE_CHUNKS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('UPDATE_SOURCE_CHUNKS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('DELETE_SOURCE_CHUNKS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('CREATE_AI_JOBS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_AI_JOBS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('UPDATE_AI_JOBS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('DELETE_AI_JOBS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('CREATE_CONCEPT_MAPS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_CONCEPT_MAPS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('UPDATE_CONCEPT_MAPS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('DELETE_CONCEPT_MAPS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('CREATE_STUDY_GUIDES') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_STUDY_GUIDES') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('UPDATE_STUDY_GUIDES') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('DELETE_STUDY_GUIDES') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('CREATE_FLASHCARD_DECKS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_FLASHCARD_DECKS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('UPDATE_FLASHCARD_DECKS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('DELETE_FLASHCARD_DECKS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('CREATE_FLASHCARDS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_FLASHCARDS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('UPDATE_FLASHCARDS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('DELETE_FLASHCARDS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('CREATE_SPACED_REPETITION_STATES') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_SPACED_REPETITION_STATES') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('UPDATE_SPACED_REPETITION_STATES') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('DELETE_SPACED_REPETITION_STATES') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('CREATE_STUDY_SESSIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_STUDY_SESSIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('UPDATE_STUDY_SESSIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('DELETE_STUDY_SESSIONS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('CREATE_REVIEW_EVENTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_REVIEW_EVENTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('UPDATE_REVIEW_EVENTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('DELETE_REVIEW_EVENTS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('CREATE_QUIZZES') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_QUIZZES') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('UPDATE_QUIZZES') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('DELETE_QUIZZES') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('CREATE_QUIZ_QUESTIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_QUIZ_QUESTIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('UPDATE_QUIZ_QUESTIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('DELETE_QUIZ_QUESTIONS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('CREATE_QUIZ_ATTEMPTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_QUIZ_ATTEMPTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('UPDATE_QUIZ_ATTEMPTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('DELETE_QUIZ_ATTEMPTS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('CREATE_TUTOR_CONVERSATIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_TUTOR_CONVERSATIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('UPDATE_TUTOR_CONVERSATIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('DELETE_TUTOR_CONVERSATIONS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('CREATE_TUTOR_MESSAGES') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_TUTOR_MESSAGES') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('UPDATE_TUTOR_MESSAGES') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('DELETE_TUTOR_MESSAGES') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('CREATE_STUDY_PLANS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_STUDY_PLANS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('UPDATE_STUDY_PLANS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('DELETE_STUDY_PLANS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('CREATE_STUDY_PLAN_ITEMS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_STUDY_PLAN_ITEMS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('UPDATE_STUDY_PLAN_ITEMS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('DELETE_STUDY_PLAN_ITEMS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('CREATE_DASHBOARD_SNAPSHOTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_DASHBOARD_SNAPSHOTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('UPDATE_DASHBOARD_SNAPSHOTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('DELETE_DASHBOARD_SNAPSHOTS') },
    
    
    
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_API_DOCS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('CREATE_SEARCH') },
    
    { 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("WorkspaceOwner")}' WHERE "email"='client@hello.com'`);
        await queryInterface.sequelize.query(`UPDATE "users" SET "app_roleId"='${getId("WorkspaceManager")}' WHERE "email"='john@doe.com'`);
       
      
      

}
};

