Covivo/mobicoop

View on GitHub
api/src/Migrations/Version20200215143800.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
 * Auto-generated Migration: Please modify to your needs!
 */
final class Version20200215143800 extends AbstractMigration
{
    public function up(Schema $schema) : void
    {
        // this up() migration is auto-generated, please modify it to your needs
        $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

        $this->addSql('
            UPDATE `role` SET `title`=\'Super admin\', `name`=\'ROLE_SUPER_ADMIN\', `parent_id`=NULL WHERE `id`=1;
            UPDATE `role` SET `title`=\'Admin\', `name`=\'ROLE_ADMIN \', `parent_id`=1 WHERE `id`=2;
            UPDATE `role` SET `title`=\'User with full registration\', `name`=\'ROLE_USER_REGISTERED_FULL \', `parent_id`=2 WHERE `id`=3;
            UPDATE `role` SET `title`=\'User with minimal registration\', `name`=\'ROLE_USER_REGISTERED_MINIMAL \', `parent_id`=3 WHERE `id`=4;
            UPDATE `role` SET `title`=\'Unregistered or disconnected user\', `name`=\'ROLE_USER \', `parent_id`=4 WHERE `id`=5;
            UPDATE `role` SET `title`=\'Mobimatch user\', `name`=\'ROLE_MASS_MATCH \', `parent_id`=2 WHERE `id`=6;
            INSERT INTO `role` (`id`, `title`, `name`, `parent_id`) VALUES
            (7,  \'Community manager \',  \'ROLE_COMMUNITY_MANAGER \', 2),
            (8,  \'Solidary manager \',  \'ROLE_SOLIDARY_MANAGER \', 2),
            (9,  \'Communication manager \',  \'ROLE_COMMUNICATION_MANAGER \', 2);
        ');
        $this->addSql('DELETE FROM role_right;');
        $this->addSql('DELETE FROM user_right;');
        $this->addSql('DELETE FROM uright;');
        $this->addSql('
        INSERT INTO `uright` (`id`, `name`, `description`, `object`) VALUES
        (1, \'user_register\', \'Minimal registration\', NULL),
        (2, \'user_register_full\', \'Full registration\', NULL),
        (3, \'user_create\', \'Create a user\', NULL),
        (4, \'user_read\', \'View a user\', NULL),
        (5, \'user_update\', \'Update a user\', NULL),
        (6, \'user_delete\', \'Delete a user\', NULL),
        (7, \'user_list\', \'View the list of users\', NULL),
        (8, \'user_password\', \'Change user password\', NULL),
        (9, \'user_update_self\', \'Update its own profile\', \'user\'),
        (10, \'user_delete_self\', \'Delete its own profile\', \'user\'),
        (11, \'user_password_self\', \'Change its own password\', \'user\'),
        (12, \'user_message_create\', \'Create a message\', NULL),
        (13, \'user_message_read\', \'Read a message of a user\', NULL),
        (14, \'user_message_delete\', \'Delete a message of a user\', NULL),
        (15, \'user_message_read_self\', \'Read its own messages\', \'message()\'),
        (16, \'user_message_delete_self\', \'Delete its own messages\', \'message\'),
        (17, \'ad_create\', \'Create an ad\', NULL),
        (18, \'ad_read\', \'View a user ad\', NULL),
        (19, \'ad_update\', \'Update an ad for a user\', NULL),
        (20, \'ad_delete\', \'Delete an ad for a user\', NULL),
        (21, \'ad_list\', \'View a list of ads\', NULL),
        (22, \'ad_search_create\', \'Create an unpublished search ad and get the results\', NULL),
        (23, \'ad_results\', \'View the results of an ad\', NULL),
        (24, \'ad_create_delegate\', \'Create an ad for a user\', NULL),
        (25, \'ad_update_self\', \'Update its own ad\', \'ad\'),
        (26, \'ad_delete_self\', \'Delete its own ad\', \'ad\'),
        (27, \'ad_results_self\', \'View the results of its own ad\', \'ad\'),
        (28, \'article_create\', \'Create an article\', NULL),
        (29, \'article_read\', \'Read an article\', NULL),
        (30, \'article_update\', \'Update an article\', NULL),
        (31, \'article_delete\', \'Delete an article\', NULL),
        (32, \'article_list\', \'View the list of articles\', NULL),
        (33, \'community_create\', \'Create a community\', NULL),
        (34, \'community_private_create\', \'Create a private community\', NULL),
        (35, \'community_read\', \'View a community\', NULL),
        (36, \'community_private_read\', \'View a private community\', \'communityJoined()\'),
        (37, \'community_update\', \'Update a community\', NULL),
        (38, \'community_delete\', \'Delete a community\', NULL),
        (39, \'community_list\', \'View the list of communities\', NULL),
        (40, \'community_membership\', \'Manage a community membership\', NULL),
        (41, \'community_membership_self\', \'Manage its managed community membership\', \'communityManaged()\'),
        (42, \'community_update_self\', \'Update its managed community\', \'communityManaged()\'),
        (43, \'community_delete_self\', \'Delete its managed community\', \'communityManaged()\'),
        (44, \'community_join\', \'Join/leave a community\', NULL),
        (45, \'community_join_private\', \'Join/leave a private community\', NULL),
        (46, \'event_create\', \'Create an event\', NULL),
        (47, \'event_read\', \'View an event\', NULL),
        (48, \'event_update\', \'Update an event\', NULL),
        (49, \'event_delete\', \'Delete an event\', NULL),
        (50, \'event_list\', \'View the list of events\', NULL),
        (51, \'event_update_self\', \'Update its own event\', \'event\'),
        (52, \'event_delete_self\', \'Delete its own event\', \'event\'),
        (53, \'relay_point_create\', \'Create a relay point\', NULL),
        (54, \'relay_point_read\', \'View a relay point\', NULL),
        (55, \'relay_point_update\', \'Update a relay point\', NULL),
        (56, \'relay_point_delete\', \'Delete a relay point\', NULL),
        (57, \'relay_point_update_self\', \'Update its own relay point\', \'relaypoint\'),
        (58, \'relay_point_delete_self\', \'Delete its own relay point\', \'relaypoint\'),
        (59, \'relay_point_type_create\', \'Create a relay point type\', NULL),
        (60, \'relay_point_type_read\', \'View a relay point type\', NULL),
        (61, \'relay_point_type_update\', \'Update a relay point type\', NULL),
        (62, \'relay_point_type_delete\', \'Delete a relay point type\', NULL),
        (63, \'relay_point_type_update_self\', \'Update its own relay point type\', \'relaypointtype\'),
        (64, \'relay_point_type_delete_self\', \'Delete its own relay point type\', \'relaypointtype\'),
        (65, \'territory_create\', \'Create a territory\', NULL),
        (66, \'territory_read\', \'Read a territory\', NULL),
        (67, \'territory_update\', \'Update a territory\', NULL),
        (68, \'territory_delete\', \'Delete a territory\', NULL),
        (69, \'mass_create\', \'Create mass matching data\', NULL),
        (70, \'mass_read\', \'Read a mass matching data\', NULL),
        (71, \'mass_delete\', \'Delete mass matching data\', NULL),
        (72, \'mass_read_self\', \'Read its own mass matching data\', \'mass\'),
        (73, \'mass_delete_self\', \'Delete its own mass matching data\', \'mass\'),
        (74, \'solidary_create\', \'Create a solidary record\', NULL),
        (75, \'solidary_read\', \'Read a solidary record\', NULL),
        (76, \'solidary_update\', \'Update a solidary record\', NULL),
        (77, \'solidary_delete\', \'Delete a solidary record\', NULL),
        (78, \'campaign_create\', \'Create a campaign\', NULL),
        (79, \'campaign_read\', \'View a campaign\', NULL),
        (80, \'campaign_update\', \'Update a campaign\', NULL),
        (81, \'campaign_delete\', \'Delete a campaign\', NULL),
        (82, \'campaign_read_self\', \'View its own campaign\', \'campaign\'),
        (83, \'campaign_update_self\', \'Update its own campaign\', \'campaign\'),
        (84, \'campaign_delete_self\', \'Delete its own campaign\', \'campaign\'),
        (85, \'check_permission\', \'Check permission\', NULL),
        (86, \'check_permission_self\', \'Check permission for own objects\', NULL),
        (87, \'access_admin\', \'Get access to administration\', NULL),
        (88, \'communication_contact\', \'Send a contact message\', NULL),
        (89, \'role_assign\', \'Assign a role to a user\', \'role()\'),
        (90, \'right_role_assign\', \'Assign a right to a role\', NULL),
        (91, \'right_user_assign\', \'Assign a right to a user\', NULL),
        (92, \'ad_ask_create\', \'Create an ask for an ad\', \'canCreateAsk()\'),
        (93, \'user_manage\', \'Manage users\', NULL),
        (94, \'user_message_manage\', \'Manage users messages\', NULL),
        (95, \'ad_manage\', \'Manage carpool data\', NULL),
        (96, \'article_manage\', \'Manage articles\', NULL),
        (97, \'community_manage\', \'Manage communities\', NULL),
        (98, \'event_manage\', \'Manage events\', NULL),
        (99, \'relay_point_manage\', \'Manage relay points\', NULL),
        (100, \'territory_manage\', \'Manage territories\', NULL),
        (101, \'mass_manage\', \'Manage mass matching data\', NULL),
        (102, \'permission_manage\', \'Manage permissions\', NULL),
        (103, \'solidary_manage\', \'Manage solidary data\', NULL),
        (104, \'mass_communication_manage\', \'Manage communication campaigns\', NULL);
        ');


        $this->addSql('
        INSERT INTO `role_right` (`role_id`, `right_id`) VALUES
        (1, 89),
        (1, 90),
        (1, 91),
        (1, 102),
        (2, 3),
        (2, 4),
        (2, 5),
        (2, 6),
        (2, 7),
        (2, 8),
        (2, 13),
        (2, 14),
        (2, 18),
        (2, 19),
        (2, 20),
        (2, 21),
        (2, 24),
        (2, 28),
        (2, 30),
        (2, 31),
        (2, 32),
        (2, 37),
        (2, 38),
        (2, 48),
        (2, 49),
        (2, 55),
        (2, 56),
        (2, 59),
        (2, 60),
        (2, 61),
        (2, 62),
        (2, 65),
        (2, 66),
        (2, 67),
        (2, 68),
        (2, 70),
        (2, 71),
        (2, 79),
        (2, 80),
        (2, 81),
        (2, 93),
        (2, 94),
        (2, 95),
        (2, 96),
        (2, 98),
        (2, 99),
        (2, 100),
        (3, 33),
        (3, 34),
        (3, 35),
        (3, 36),
        (3, 44),
        (3, 45),
        (3, 46),
        (3, 47),
        (3, 51),
        (3, 52),
        (3, 53),
        (3, 57),
        (3, 58),
        (3, 63),
        (3, 64),
        (3, 74),
        (4, 9),
        (4, 10),
        (4, 11),
        (4, 12),
        (4, 15),
        (4, 16),
        (4, 17),
        (4, 23),
        (4, 25),
        (4, 26),
        (4, 27),
        (4, 86),
        (4, 92),
        (5, 1),
        (5, 2),
        (5, 22),
        (5, 29),
        (5, 39),
        (5, 50),
        (5, 54),
        (5, 85),
        (5, 88),
        (6, 69),
        (6, 72),
        (6, 73),
        (6, 87),
        (6, 101),
        (7, 40),
        (7, 41),
        (7, 42),
        (7, 43),
        (7, 87),
        (7, 97),
        (8, 75),
        (8, 76),
        (8, 77),
        (8, 87),
        (8, 103),
        (9, 78),
        (9, 82),
        (9, 83),
        (9, 84),
        (9, 87),
        (9, 104);
        ');
    }

    public function down(Schema $schema) : void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
    }
}