
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("Owner"), name: "Owner", createdAt, updatedAt },
        
          { id: getId("ProjectManager"), name: "Project Manager", createdAt, updatedAt },
        
          { id: getId("Editor"), name: "Editor", createdAt, updatedAt },
        
          { id: getId("Contributor"), name: "Contributor", createdAt, updatedAt },
        
          { id: getId("Viewer"), name: "Viewer", 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","projects","pages","components","layers","assets","versions","builds","styles","teams",,
    ];
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("Owner"), permissionId: getId('CREATE_USERS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('READ_USERS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('UPDATE_USERS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('DELETE_USERS') },
                    
                  
                  
                
               
                
                  
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ProjectManager"), permissionId: getId('READ_USERS') },
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Editor"), permissionId: getId('READ_USERS') },
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Viewer"), permissionId: getId('READ_USERS') },
                    
                  
                    
                  
                    
                  
                  
             
          
    
  
    
    
    
    
      
      
          
                
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('CREATE_PROJECTS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('READ_PROJECTS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('UPDATE_PROJECTS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('DELETE_PROJECTS') },
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ProjectManager"), permissionId: getId('CREATE_PROJECTS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ProjectManager"), permissionId: getId('READ_PROJECTS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ProjectManager"), permissionId: getId('UPDATE_PROJECTS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ProjectManager"), permissionId: getId('DELETE_PROJECTS') },
                    
                  
                  
                
               
                
                  
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Editor"), permissionId: getId('READ_PROJECTS') },
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Contributor"), permissionId: getId('READ_PROJECTS') },
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Viewer"), permissionId: getId('READ_PROJECTS') },
                    
                  
                    
                  
                    
                  
                  
             
          
    
  
    
    
      
      
          
                
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('CREATE_PAGES') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('READ_PAGES') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('UPDATE_PAGES') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('DELETE_PAGES') },
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ProjectManager"), permissionId: getId('CREATE_PAGES') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ProjectManager"), permissionId: getId('READ_PAGES') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ProjectManager"), permissionId: getId('UPDATE_PAGES') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ProjectManager"), permissionId: getId('DELETE_PAGES') },
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Editor"), permissionId: getId('CREATE_PAGES') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Editor"), permissionId: getId('READ_PAGES') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Editor"), permissionId: getId('UPDATE_PAGES') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Editor"), permissionId: getId('DELETE_PAGES') },
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Contributor"), permissionId: getId('CREATE_PAGES') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Contributor"), permissionId: getId('READ_PAGES') },
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Viewer"), permissionId: getId('READ_PAGES') },
                    
                  
                    
                  
                    
                  
                  
             
          
    
  
    
    
      
      
          
                
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('CREATE_COMPONENTS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('READ_COMPONENTS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('UPDATE_COMPONENTS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('DELETE_COMPONENTS') },
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ProjectManager"), permissionId: getId('CREATE_COMPONENTS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ProjectManager"), permissionId: getId('READ_COMPONENTS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ProjectManager"), permissionId: getId('UPDATE_COMPONENTS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ProjectManager"), permissionId: getId('DELETE_COMPONENTS') },
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Editor"), permissionId: getId('CREATE_COMPONENTS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Editor"), permissionId: getId('READ_COMPONENTS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Editor"), permissionId: getId('UPDATE_COMPONENTS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Editor"), permissionId: getId('DELETE_COMPONENTS') },
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Contributor"), permissionId: getId('CREATE_COMPONENTS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Contributor"), permissionId: getId('READ_COMPONENTS') },
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Viewer"), permissionId: getId('READ_COMPONENTS') },
                    
                  
                    
                  
                    
                  
                  
             
          
    
  
    
    
      
      
          
                
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('CREATE_LAYERS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('READ_LAYERS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('UPDATE_LAYERS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('DELETE_LAYERS') },
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ProjectManager"), permissionId: getId('CREATE_LAYERS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ProjectManager"), permissionId: getId('READ_LAYERS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ProjectManager"), permissionId: getId('UPDATE_LAYERS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ProjectManager"), permissionId: getId('DELETE_LAYERS') },
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Editor"), permissionId: getId('CREATE_LAYERS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Editor"), permissionId: getId('READ_LAYERS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Editor"), permissionId: getId('UPDATE_LAYERS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Editor"), permissionId: getId('DELETE_LAYERS') },
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Contributor"), permissionId: getId('CREATE_LAYERS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Contributor"), permissionId: getId('READ_LAYERS') },
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Viewer"), permissionId: getId('READ_LAYERS') },
                    
                  
                    
                  
                    
                  
                  
             
          
    
  
    
    
      
      
          
                
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('CREATE_ASSETS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('READ_ASSETS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('UPDATE_ASSETS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('DELETE_ASSETS') },
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ProjectManager"), permissionId: getId('CREATE_ASSETS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ProjectManager"), permissionId: getId('READ_ASSETS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ProjectManager"), permissionId: getId('UPDATE_ASSETS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ProjectManager"), permissionId: getId('DELETE_ASSETS') },
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Editor"), permissionId: getId('CREATE_ASSETS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Editor"), permissionId: getId('READ_ASSETS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Editor"), permissionId: getId('UPDATE_ASSETS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Editor"), permissionId: getId('DELETE_ASSETS') },
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Contributor"), permissionId: getId('CREATE_ASSETS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Contributor"), permissionId: getId('READ_ASSETS') },
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Viewer"), permissionId: getId('READ_ASSETS') },
                    
                  
                    
                  
                    
                  
                  
             
          
    
  
    
    
      
      
          
                
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('CREATE_VERSIONS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('READ_VERSIONS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('UPDATE_VERSIONS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('DELETE_VERSIONS') },
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ProjectManager"), permissionId: getId('CREATE_VERSIONS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ProjectManager"), permissionId: getId('READ_VERSIONS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ProjectManager"), permissionId: getId('UPDATE_VERSIONS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ProjectManager"), permissionId: getId('DELETE_VERSIONS') },
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Editor"), permissionId: getId('CREATE_VERSIONS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Editor"), permissionId: getId('READ_VERSIONS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Editor"), permissionId: getId('UPDATE_VERSIONS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Editor"), permissionId: getId('DELETE_VERSIONS') },
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Contributor"), permissionId: getId('CREATE_VERSIONS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Contributor"), permissionId: getId('READ_VERSIONS') },
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Viewer"), permissionId: getId('READ_VERSIONS') },
                    
                  
                    
                  
                    
                  
                  
             
          
    
  
    
    
      
      
          
                
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('CREATE_BUILDS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('READ_BUILDS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('UPDATE_BUILDS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('DELETE_BUILDS') },
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ProjectManager"), permissionId: getId('CREATE_BUILDS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ProjectManager"), permissionId: getId('READ_BUILDS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ProjectManager"), permissionId: getId('UPDATE_BUILDS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ProjectManager"), permissionId: getId('DELETE_BUILDS') },
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Editor"), permissionId: getId('CREATE_BUILDS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Editor"), permissionId: getId('READ_BUILDS') },
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Contributor"), permissionId: getId('CREATE_BUILDS') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Viewer"), permissionId: getId('READ_BUILDS') },
                    
                  
                    
                  
                    
                  
                  
             
          
    
  
    
    
      
      
          
                
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('CREATE_STYLES') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('READ_STYLES') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('UPDATE_STYLES') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('DELETE_STYLES') },
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ProjectManager"), permissionId: getId('CREATE_STYLES') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ProjectManager"), permissionId: getId('READ_STYLES') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ProjectManager"), permissionId: getId('UPDATE_STYLES') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ProjectManager"), permissionId: getId('DELETE_STYLES') },
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Editor"), permissionId: getId('CREATE_STYLES') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Editor"), permissionId: getId('READ_STYLES') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Editor"), permissionId: getId('UPDATE_STYLES') },
                    
                  
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Contributor"), permissionId: getId('CREATE_STYLES') },
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Viewer"), permissionId: getId('READ_STYLES') },
                    
                  
                    
                  
                    
                  
                  
             
          
    
  
    
    
      
      
          
                
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('CREATE_TEAMS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('READ_TEAMS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('UPDATE_TEAMS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('DELETE_TEAMS') },
                    
                  
                  
                
               
                
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ProjectManager"), permissionId: getId('CREATE_TEAMS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ProjectManager"), permissionId: getId('READ_TEAMS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ProjectManager"), permissionId: getId('UPDATE_TEAMS') },
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("ProjectManager"), permissionId: getId('DELETE_TEAMS') },
                    
                  
                  
                
               
                
                  
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Editor"), permissionId: getId('READ_TEAMS') },
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                  
                    
                  
                    
                  
                  
                
               
                
                  
                    
                  
                    
                      { createdAt, updatedAt, roles_permissionsId: getId("Viewer"), permissionId: getId('READ_TEAMS') },
                    
                  
                    
                  
                    
                  
                  
             
          
    
  
    
     
  
      
      
        
            { createdAt, updatedAt, roles_permissionsId: getId("Owner"), permissionId: getId('CREATE_SEARCH') },
        
            { createdAt, updatedAt, roles_permissionsId: getId("ProjectManager"), permissionId: getId('CREATE_SEARCH') },
        
            { createdAt, updatedAt, roles_permissionsId: getId("Editor"), permissionId: getId('CREATE_SEARCH') },
        
            { createdAt, updatedAt, roles_permissionsId: getId("Contributor"), permissionId: getId('CREATE_SEARCH') },
        
            { createdAt, updatedAt, roles_permissionsId: getId("Viewer"), 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_PROJECTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_PROJECTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_PROJECTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_PROJECTS') },
    
    { 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_COMPONENTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_COMPONENTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_COMPONENTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_COMPONENTS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_LAYERS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_LAYERS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_LAYERS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_LAYERS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_ASSETS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_ASSETS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_ASSETS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_ASSETS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_VERSIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_VERSIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_VERSIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_VERSIONS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_BUILDS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_BUILDS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_BUILDS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_BUILDS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_STYLES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_STYLES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_STYLES') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_STYLES') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_TEAMS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_TEAMS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_TEAMS') },
    { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_TEAMS') },
    
    
    
    { 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_PROJECTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_PROJECTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('UPDATE_PROJECTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('DELETE_PROJECTS') },
    
    { 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_COMPONENTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_COMPONENTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('UPDATE_COMPONENTS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('DELETE_COMPONENTS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('CREATE_LAYERS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_LAYERS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('UPDATE_LAYERS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('DELETE_LAYERS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('CREATE_ASSETS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_ASSETS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('UPDATE_ASSETS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('DELETE_ASSETS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('CREATE_VERSIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_VERSIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('UPDATE_VERSIONS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('DELETE_VERSIONS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('CREATE_BUILDS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_BUILDS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('UPDATE_BUILDS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('DELETE_BUILDS') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('CREATE_STYLES') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_STYLES') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('UPDATE_STYLES') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('DELETE_STYLES') },
    
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('CREATE_TEAMS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('READ_TEAMS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('UPDATE_TEAMS') },
    { createdAt, updatedAt, roles_permissionsId: getId("SuperAdmin"), permissionId: getId('DELETE_TEAMS') },
    
    
    
    { 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("Owner")}' WHERE "email"='client@hello.com'`);
        await queryInterface.sequelize.query(`UPDATE "users" SET "app_roleId"='${getId("ProjectManager")}' WHERE "email"='john@doe.com'`);
       
      
      

}
};

