Completed
Push — master ( 42c822...2f39ac )
by Jan
04:38
created

Version20190805165134::down()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 114
Code Lines 109

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 109
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 114
rs 8

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
declare(strict_types=1);
4
5
namespace DoctrineMigrations;
6
7
use Doctrine\DBAL\DBALException;
8
use Doctrine\DBAL\Exception\TableNotFoundException;
9
use Doctrine\DBAL\Schema\Schema;
10
use Doctrine\Migrations\AbstractMigration;
11
12
/**
13
 * Auto-generated Migration: Please modify to your needs!
14
 */
15
final class Version20190805165134 extends AbstractMigration
16
{
17
    public function getDescription() : string
18
    {
19
        return '';
20
    }
21
22
    public function up(Schema $schema) : void
23
    {
24
25
        //Deactive SQL Modes (especially NO_ZERO_DATE, which prevents updating)
26
        $this->addSql("SET sql_mode = ''");
27
28
        // this up() migration is auto-generated, please modify it to your needs
29
        $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
30
31
32
        $skip_this_version = false;
0 ignored issues
show
Unused Code introduced by
The assignment to $skip_this_version is dead and can be removed.
Loading history...
33
        try {
34
            //Check if we can use this migration method:
35
            $version = (int)$this->connection->fetchColumn("SELECT keyValue AS version FROM `internal` WHERE `keyName` = 'dbVersion'");
36
37
            $this->abortIf($version !== 26, "This database migration can only be used if the database version is 26! Install Part-DB 0.5.6 and update database there!");
38
39
        } catch (DBALException $ex) {
40
            //when the table was not found, then you can not use this migration
41
            $this->skipIf(true, "Empty database detected. Skip migration.");
42
        }
43
44
        $this->addSql('ALTER TABLE attachements DROP FOREIGN KEY attachements_type_id_fk');
45
        $this->addSql('ALTER TABLE attachements ADD datetime_added DATETIME NOT NULL, CHANGE type_id type_id INT DEFAULT NULL, CHANGE name name VARCHAR(255) NOT NULL, CHANGE element_id element_id INT DEFAULT NULL, CHANGE filename filename VARCHAR(255) NOT NULL, CHANGE show_in_table show_in_table TINYINT(1) NOT NULL, CHANGE last_modified last_modified DATETIME NOT NULL');
46
        $this->addSql('ALTER TABLE attachements ADD CONSTRAINT FK_212B82DC1F1F2A24 FOREIGN KEY (element_id) REFERENCES `parts` (id)');
47
        $this->addSql('CREATE INDEX IDX_212B82DC1F1F2A24 ON attachements (element_id)');
48
        $this->addSql('CREATE INDEX IDX_212B82DCC54C8C93 ON attachements (type_id)');
49
        $this->addSql('ALTER TABLE attachements ADD CONSTRAINT attachements_type_id_fk FOREIGN KEY (type_id) REFERENCES attachement_types (id)');
50
        $this->addSql('ALTER TABLE attachement_types DROP FOREIGN KEY attachement_types_parent_id_fk');
51
        $this->addSql('ALTER TABLE attachement_types CHANGE parent_id parent_id INT DEFAULT NULL, CHANGE name name VARCHAR(255) NOT NULL, CHANGE comment comment LONGTEXT NOT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL, CHANGE last_modified last_modified DATETIME NOT NULL');
52
        $this->addSql('CREATE INDEX IDX_9A8C1C77727ACA70 ON attachement_types (parent_id)');
53
        $this->addSql('ALTER TABLE attachement_types ADD CONSTRAINT attachement_types_parent_id_fk FOREIGN KEY (parent_id) REFERENCES attachement_types (id)');
54
        $this->addSql('ALTER TABLE categories DROP FOREIGN KEY categories_parent_id_fk');
55
        $this->addSql('ALTER TABLE categories CHANGE parent_id parent_id INT DEFAULT NULL, CHANGE name name VARCHAR(255) NOT NULL, CHANGE disable_footprints disable_footprints TINYINT(1) NOT NULL, CHANGE disable_manufacturers disable_manufacturers TINYINT(1) NOT NULL, CHANGE disable_autodatasheets disable_autodatasheets TINYINT(1) NOT NULL, CHANGE disable_properties disable_properties TINYINT(1) NOT NULL, CHANGE comment comment LONGTEXT NOT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL, CHANGE last_modified last_modified DATETIME NOT NULL');
56
        $this->addSql('CREATE INDEX IDX_3AF34668727ACA70 ON categories (parent_id)');
57
        $this->addSql('ALTER TABLE categories ADD CONSTRAINT categories_parent_id_fk FOREIGN KEY (parent_id) REFERENCES categories (id)');
58
        $this->addSql('ALTER TABLE devices DROP FOREIGN KEY devices_parent_id_fk');
59
        $this->addSql('ALTER TABLE devices CHANGE parent_id parent_id INT DEFAULT NULL, CHANGE name name VARCHAR(255) NOT NULL, CHANGE order_quantity order_quantity INT NOT NULL, CHANGE order_only_missing_parts order_only_missing_parts TINYINT(1) NOT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL, CHANGE last_modified last_modified DATETIME NOT NULL, CHANGE comment comment LONGTEXT NOT NULL');
60
        $this->addSql('CREATE INDEX IDX_11074E9A727ACA70 ON devices (parent_id)');
61
        $this->addSql('ALTER TABLE devices ADD CONSTRAINT devices_parent_id_fk FOREIGN KEY (parent_id) REFERENCES devices (id)');
62
        $this->addSql('ALTER TABLE device_parts CHANGE id_part id_part INT DEFAULT NULL, CHANGE id_device id_device INT DEFAULT NULL, CHANGE quantity quantity INT NOT NULL');
63
        $this->addSql('ALTER TABLE device_parts ADD CONSTRAINT FK_AFC547992F180363 FOREIGN KEY (id_device) REFERENCES `devices` (id)');
64
        $this->addSql('ALTER TABLE device_parts ADD CONSTRAINT FK_AFC54799C22F6CC4 FOREIGN KEY (id_part) REFERENCES `parts` (id)');
65
        $this->addSql('CREATE INDEX IDX_AFC547992F180363 ON device_parts (id_device)');
66
        $this->addSql('DROP INDEX device_parts_id_part_k ON device_parts');
67
        $this->addSql('CREATE INDEX IDX_AFC54799C22F6CC4 ON device_parts (id_part)');
68
        $this->addSql('ALTER TABLE footprints DROP FOREIGN KEY footprints_parent_id_fk');
69
        $this->addSql('ALTER TABLE footprints CHANGE parent_id parent_id INT DEFAULT NULL, CHANGE name name VARCHAR(255) NOT NULL, CHANGE filename filename MEDIUMTEXT NOT NULL, CHANGE filename_3d filename_3d MEDIUMTEXT NOT NULL, CHANGE comment comment LONGTEXT NOT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL, CHANGE last_modified last_modified DATETIME NOT NULL');
70
        $this->addSql('CREATE INDEX IDX_A34D68A2727ACA70 ON footprints (parent_id)');
71
        $this->addSql('ALTER TABLE footprints ADD CONSTRAINT footprints_parent_id_fk FOREIGN KEY (parent_id) REFERENCES footprints (id)');
72
        $this->addSql('ALTER TABLE `groups` CHANGE name name VARCHAR(255) NOT NULL, CHANGE parent_id parent_id INT DEFAULT NULL, CHANGE comment comment LONGTEXT NOT NULL, CHANGE perms_labels perms_labels INT NOT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL, CHANGE last_modified last_modified DATETIME NOT NULL');
73
        $this->addSql('ALTER TABLE `groups` ADD CONSTRAINT FK_F06D3970727ACA70 FOREIGN KEY (parent_id) REFERENCES `groups` (id)');
74
        $this->addSql('CREATE INDEX IDX_F06D3970727ACA70 ON `groups` (parent_id)');
75
        $this->addSql('ALTER TABLE manufacturers DROP FOREIGN KEY manufacturers_parent_id_fk');
76
        $this->addSql('ALTER TABLE manufacturers CHANGE parent_id parent_id INT DEFAULT NULL, CHANGE name name VARCHAR(255) NOT NULL, CHANGE address address VARCHAR(255) NOT NULL, CHANGE phone_number phone_number VARCHAR(255) NOT NULL, CHANGE fax_number fax_number VARCHAR(255) NOT NULL, CHANGE email_address email_address VARCHAR(255) NOT NULL, CHANGE website website VARCHAR(255) NOT NULL, CHANGE auto_product_url auto_product_url VARCHAR(255) NOT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL, CHANGE comment comment LONGTEXT NOT NULL, CHANGE last_modified last_modified DATETIME NOT NULL');
77
        $this->addSql('CREATE INDEX IDX_94565B12727ACA70 ON manufacturers (parent_id)');
78
        $this->addSql('ALTER TABLE manufacturers ADD CONSTRAINT manufacturers_parent_id_fk FOREIGN KEY (parent_id) REFERENCES manufacturers (id)');
79
        $this->addSql('ALTER TABLE orderdetails CHANGE part_id part_id INT DEFAULT NULL, CHANGE id_supplier id_supplier INT DEFAULT NULL, CHANGE supplierpartnr supplierpartnr VARCHAR(255) NOT NULL, CHANGE obsolete obsolete TINYINT(1) NOT NULL, CHANGE supplier_product_url supplier_product_url VARCHAR(255) NOT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL');
80
        $this->addSql('ALTER TABLE orderdetails ADD CONSTRAINT FK_489AFCDC4CE34BEC FOREIGN KEY (part_id) REFERENCES `parts` (id)');
81
        $this->addSql('ALTER TABLE orderdetails ADD CONSTRAINT FK_489AFCDCCBF180EB FOREIGN KEY (id_supplier) REFERENCES `suppliers` (id)');
82
        $this->addSql('CREATE INDEX IDX_489AFCDC4CE34BEC ON orderdetails (part_id)');
83
        $this->addSql('CREATE INDEX IDX_489AFCDCCBF180EB ON orderdetails (id_supplier)');
84
        $this->addSql('ALTER TABLE parts DROP INDEX parts_order_orderdetails_id_k, ADD UNIQUE INDEX UNIQ_6940A7FE81081E9B (order_orderdetails_id)');
85
        $this->addSql('ALTER TABLE parts DROP FOREIGN KEY parts_id_footprint_fk');
86
        $this->addSql('ALTER TABLE parts DROP FOREIGN KEY parts_id_manufacturer_fk');
87
        $this->addSql('ALTER TABLE parts DROP FOREIGN KEY parts_id_storelocation_fk');
88
        $this->addSql('ALTER TABLE parts CHANGE id_footprint id_footprint INT DEFAULT NULL, CHANGE id_storelocation id_storelocation INT DEFAULT NULL, CHANGE order_orderdetails_id order_orderdetails_id INT DEFAULT NULL, CHANGE id_manufacturer id_manufacturer INT DEFAULT NULL, CHANGE id_category id_category INT DEFAULT NULL, CHANGE name name VARCHAR(255) NOT NULL, CHANGE instock instock INT NOT NULL, CHANGE mininstock mininstock INT NOT NULL, CHANGE order_quantity order_quantity INT NOT NULL, CHANGE manual_order manual_order TINYINT(1) NOT NULL, CHANGE id_master_picture_attachement id_master_picture_attachement INT DEFAULT NULL, CHANGE manufacturer_product_url manufacturer_product_url VARCHAR(255) NOT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL, CHANGE last_modified last_modified DATETIME NOT NULL, CHANGE favorite favorite TINYINT(1) NOT NULL');
89
        $this->addSql('ALTER TABLE parts ADD CONSTRAINT FK_6940A7FE5697F554 FOREIGN KEY (id_category) REFERENCES `categories` (id)');
90
        $this->addSql('ALTER TABLE parts ADD CONSTRAINT FK_6940A7FEEBBCC786 FOREIGN KEY (id_master_picture_attachement) REFERENCES `attachements` (id)');
91
        $this->addSql('CREATE INDEX IDX_6940A7FEEBBCC786 ON parts (id_master_picture_attachement)');
92
        $this->addSql('CREATE INDEX IDX_6940A7FE5697F554 ON parts (id_category)');
93
        $this->addSql('CREATE INDEX IDX_6940A7FE7E371A10 ON parts (id_footprint)');
94
        $this->addSql('DROP INDEX parts_id_storelocation_k ON parts');
95
        $this->addSql('CREATE INDEX IDX_6940A7FE8DF69834 ON parts (id_storelocation)');
96
        $this->addSql('CREATE INDEX IDX_6940A7FE1ECB93AE ON parts (id_manufacturer)');
97
        $this->addSql('ALTER TABLE parts ADD CONSTRAINT parts_id_footprint_fk FOREIGN KEY (id_footprint) REFERENCES footprints (id)');
98
        $this->addSql('ALTER TABLE parts ADD CONSTRAINT parts_id_manufacturer_fk FOREIGN KEY (id_manufacturer) REFERENCES manufacturers (id)');
99
        $this->addSql('ALTER TABLE parts ADD CONSTRAINT parts_id_storelocation_fk FOREIGN KEY (id_storelocation) REFERENCES storelocations (id)');
100
        $this->addSql('ALTER TABLE pricedetails CHANGE orderdetails_id orderdetails_id INT DEFAULT NULL, CHANGE price price NUMERIC(11, 5) NOT NULL, CHANGE price_related_quantity price_related_quantity INT NOT NULL, CHANGE min_discount_quantity min_discount_quantity INT NOT NULL, CHANGE manual_input manual_input TINYINT(1) NOT NULL, CHANGE last_modified last_modified DATETIME NOT NULL');
101
        $this->addSql('ALTER TABLE pricedetails ADD CONSTRAINT FK_C68C44594A01DDC7 FOREIGN KEY (orderdetails_id) REFERENCES `orderdetails` (id)');
102
        $this->addSql('CREATE INDEX IDX_C68C44594A01DDC7 ON pricedetails (orderdetails_id)');
103
        $this->addSql('ALTER TABLE storelocations DROP FOREIGN KEY storelocations_parent_id_fk');
104
        $this->addSql('ALTER TABLE storelocations CHANGE parent_id parent_id INT DEFAULT NULL, CHANGE name name VARCHAR(255) NOT NULL, CHANGE is_full is_full TINYINT(1) NOT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL, CHANGE comment comment LONGTEXT NOT NULL, CHANGE last_modified last_modified DATETIME NOT NULL');
105
        $this->addSql('CREATE INDEX IDX_7517020727ACA70 ON storelocations (parent_id)');
106
        $this->addSql('ALTER TABLE storelocations ADD CONSTRAINT storelocations_parent_id_fk FOREIGN KEY (parent_id) REFERENCES storelocations (id)');
107
        $this->addSql('ALTER TABLE suppliers DROP FOREIGN KEY suppliers_parent_id_fk');
108
        $this->addSql('ALTER TABLE suppliers CHANGE parent_id parent_id INT DEFAULT NULL, CHANGE name name VARCHAR(255) NOT NULL, CHANGE address address VARCHAR(255) NOT NULL, CHANGE phone_number phone_number VARCHAR(255) NOT NULL, CHANGE fax_number fax_number VARCHAR(255) NOT NULL, CHANGE email_address email_address VARCHAR(255) NOT NULL, CHANGE website website VARCHAR(255) NOT NULL, CHANGE auto_product_url auto_product_url VARCHAR(255) NOT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL, CHANGE comment comment LONGTEXT NOT NULL, CHANGE last_modified last_modified DATETIME NOT NULL');
109
110
        $this->addSql('CREATE INDEX IDX_AC28B95C727ACA70 ON suppliers (parent_id)');
111
        $this->addSql('ALTER TABLE suppliers ADD CONSTRAINT suppliers_parent_id_fk FOREIGN KEY (parent_id) REFERENCES suppliers (id)');
112
        $this->addSql('ALTER TABLE users CHANGE name name VARCHAR(180) NOT NULL, CHANGE password password VARCHAR(255) DEFAULT NULL, CHANGE first_name first_name VARCHAR(255) DEFAULT NULL, CHANGE last_name last_name VARCHAR(255) DEFAULT NULL, CHANGE department department VARCHAR(255) DEFAULT NULL, CHANGE email email VARCHAR(255) DEFAULT NULL, CHANGE need_pw_change need_pw_change TINYINT(1) NOT NULL, CHANGE group_id group_id INT DEFAULT NULL, CHANGE config_language config_language VARCHAR(255) DEFAULT NULL, CHANGE config_timezone config_timezone VARCHAR(255) DEFAULT NULL, CHANGE config_theme config_theme VARCHAR(255) DEFAULT NULL, CHANGE config_currency config_currency VARCHAR(255) NOT NULL, CHANGE perms_labels perms_labels INT NOT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL, CHANGE last_modified last_modified DATETIME NOT NULL');
113
        $this->addSql('ALTER TABLE users ADD CONSTRAINT FK_1483A5E9FE54D947 FOREIGN KEY (group_id) REFERENCES `groups` (id)');
114
        $this->addSql('CREATE INDEX IDX_1483A5E9FE54D947 ON users (group_id)');
115
116
        $this->addSql('CREATE UNIQUE INDEX UNIQ_1483A5E95E237E06 ON users (name)');
117
118
119
        //Drop indizes at last to prevent errors
120
        $this->addSql('DROP INDEX attachements_element_id_k ON attachements');
121
        $this->addSql('DROP INDEX attachements_type_id_fk ON attachements');
122
        $this->addSql('DROP INDEX attachement_types_parent_id_k ON attachement_types');
123
        $this->addSql('DROP INDEX categories_parent_id_k ON categories');
124
        $this->addSql('DROP INDEX devices_parent_id_k ON devices');
125
        $this->addSql('DROP INDEX device_parts_combination_uk ON device_parts');
126
        $this->addSql('DROP INDEX attachements_class_name_k ON attachements');
127
        $this->addSql('DROP INDEX device_parts_id_device_k ON device_parts');
128
        $this->addSql('DROP INDEX footprints_parent_id_k ON footprints');
129
        $this->addSql('DROP INDEX name ON `groups`');
130
        $this->addSql('DROP INDEX manufacturers_parent_id_k ON manufacturers');
131
        $this->addSql('DROP INDEX orderdetails_part_id_k ON orderdetails');
132
        $this->addSql('DROP INDEX orderdetails_id_supplier_k ON orderdetails');
133
        $this->addSql('DROP INDEX favorite ON parts');
134
        $this->addSql('DROP INDEX parts_id_category_k ON parts');
135
        $this->addSql('DROP INDEX parts_id_footprint_k ON parts');
136
        $this->addSql('DROP INDEX parts_id_manufacturer_k ON parts');
137
        $this->addSql('DROP INDEX pricedetails_combination_uk ON pricedetails');
138
        $this->addSql('DROP INDEX pricedetails_orderdetails_id_k ON pricedetails');
139
        $this->addSql('DROP INDEX storelocations_parent_id_k ON storelocations');
140
        $this->addSql('DROP INDEX suppliers_parent_id_k ON suppliers');
141
        $this->addSql('DROP INDEX name ON users');
142
143
        //Set the dbVersion to a high value, to prevent the old Part-DB versions to upgrade DB!
144
        $this->addSql("UPDATE `internal` SET `keyValue` = '99' WHERE `internal`.`keyName` = 'dbVersion'");
145
146
    }
147
148
    public function down(Schema $schema) : void
149
    {
150
        $this->abortIf(true, 'You can not downgrade now!');
151
152
        // this down() migration is auto-generated, please modify it to your needs
153
        $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
154
155
        $this->addSql('ALTER TABLE `attachement_types` DROP FOREIGN KEY FK_9A8C1C77727ACA70');
156
        $this->addSql('ALTER TABLE `attachement_types` CHANGE parent_id parent_id INT DEFAULT NULL, CHANGE comment comment TEXT DEFAULT NULL COLLATE utf8_unicode_ci, CHANGE name name TINYTEXT NOT NULL COLLATE utf8_unicode_ci, CHANGE last_modified last_modified DATETIME DEFAULT \'\'0000-00-00 00:00:00\'\' NOT NULL, CHANGE datetime_added datetime_added DATETIME DEFAULT \'current_timestamp()\' NOT NULL');
157
        $this->addSql('DROP INDEX idx_9a8c1c77727aca70 ON `attachement_types`');
158
        $this->addSql('CREATE INDEX attachement_types_parent_id_k ON `attachement_types` (parent_id)');
159
        $this->addSql('ALTER TABLE `attachement_types` ADD CONSTRAINT FK_9A8C1C77727ACA70 FOREIGN KEY (parent_id) REFERENCES `attachement_types` (id)');
160
        $this->addSql('ALTER TABLE `attachements` DROP FOREIGN KEY FK_212B82DC1F1F2A24');
161
        $this->addSql('ALTER TABLE `attachements` DROP FOREIGN KEY FK_212B82DCC54C8C93');
162
        $this->addSql('ALTER TABLE `attachements` DROP FOREIGN KEY FK_212B82DC1F1F2A24');
163
        $this->addSql('ALTER TABLE `attachements` DROP datetime_added, CHANGE type_id type_id INT NOT NULL, CHANGE element_id element_id INT NOT NULL, CHANGE show_in_table show_in_table TINYINT(1) DEFAULT \'0\' NOT NULL, CHANGE filename filename MEDIUMTEXT NOT NULL COLLATE utf8_unicode_ci, CHANGE name name TINYTEXT NOT NULL COLLATE utf8_unicode_ci, CHANGE last_modified last_modified DATETIME DEFAULT \'\'0000-00-00 00:00:00\'\' NOT NULL');
164
        $this->addSql('CREATE INDEX attachements_class_name_k ON `attachements` (class_name)');
165
        $this->addSql('DROP INDEX idx_212b82dc1f1f2a24 ON `attachements`');
166
        $this->addSql('CREATE INDEX attachements_element_id_k ON `attachements` (element_id)');
167
        $this->addSql('DROP INDEX idx_212b82dcc54c8c93 ON `attachements`');
168
        $this->addSql('CREATE INDEX attachements_type_id_fk ON `attachements` (type_id)');
169
        $this->addSql('ALTER TABLE `attachements` ADD CONSTRAINT FK_212B82DCC54C8C93 FOREIGN KEY (type_id) REFERENCES `attachement_types` (id)');
170
        $this->addSql('ALTER TABLE `attachements` ADD CONSTRAINT FK_212B82DC1F1F2A24 FOREIGN KEY (element_id) REFERENCES `parts` (id)');
171
        $this->addSql('ALTER TABLE `categories` DROP FOREIGN KEY FK_3AF34668727ACA70');
172
        $this->addSql('ALTER TABLE `categories` CHANGE parent_id parent_id INT DEFAULT NULL, CHANGE disable_footprints disable_footprints TINYINT(1) DEFAULT \'0\' NOT NULL, CHANGE disable_manufacturers disable_manufacturers TINYINT(1) DEFAULT \'0\' NOT NULL, CHANGE disable_autodatasheets disable_autodatasheets TINYINT(1) DEFAULT \'0\' NOT NULL, CHANGE disable_properties disable_properties TINYINT(1) DEFAULT \'0\' NOT NULL, CHANGE comment comment TEXT DEFAULT NULL COLLATE utf8_unicode_ci, CHANGE name name TINYTEXT NOT NULL COLLATE utf8_unicode_ci, CHANGE last_modified last_modified DATETIME DEFAULT \'\'0000-00-00 00:00:00\'\' NOT NULL, CHANGE datetime_added datetime_added DATETIME DEFAULT \'current_timestamp()\' NOT NULL');
173
        $this->addSql('DROP INDEX idx_3af34668727aca70 ON `categories`');
174
        $this->addSql('CREATE INDEX categories_parent_id_k ON `categories` (parent_id)');
175
        $this->addSql('ALTER TABLE `categories` ADD CONSTRAINT FK_3AF34668727ACA70 FOREIGN KEY (parent_id) REFERENCES `categories` (id)');
176
        $this->addSql('ALTER TABLE `device_parts` DROP FOREIGN KEY FK_AFC547992F180363');
177
        $this->addSql('ALTER TABLE `device_parts` DROP FOREIGN KEY FK_AFC54799C22F6CC4');
178
        $this->addSql('ALTER TABLE `device_parts` DROP FOREIGN KEY FK_AFC547992F180363');
179
        $this->addSql('ALTER TABLE `device_parts` DROP FOREIGN KEY FK_AFC54799C22F6CC4');
180
        $this->addSql('ALTER TABLE `device_parts` CHANGE id_device id_device INT DEFAULT 0 NOT NULL, CHANGE id_part id_part INT DEFAULT 0 NOT NULL, CHANGE quantity quantity INT DEFAULT 0 NOT NULL');
181
        $this->addSql('CREATE UNIQUE INDEX device_parts_combination_uk ON `device_parts` (id_part, id_device)');
182
        $this->addSql('DROP INDEX idx_afc547992f180363 ON `device_parts`');
183
        $this->addSql('CREATE INDEX device_parts_id_device_k ON `device_parts` (id_device)');
184
        $this->addSql('DROP INDEX idx_afc54799c22f6cc4 ON `device_parts`');
185
        $this->addSql('CREATE INDEX device_parts_id_part_k ON `device_parts` (id_part)');
186
        $this->addSql('ALTER TABLE `device_parts` ADD CONSTRAINT FK_AFC547992F180363 FOREIGN KEY (id_device) REFERENCES `devices` (id)');
187
        $this->addSql('ALTER TABLE `device_parts` ADD CONSTRAINT FK_AFC54799C22F6CC4 FOREIGN KEY (id_part) REFERENCES `parts` (id)');
188
        $this->addSql('ALTER TABLE `devices` DROP FOREIGN KEY FK_11074E9A727ACA70');
189
        $this->addSql('ALTER TABLE `devices` CHANGE parent_id parent_id INT DEFAULT NULL, CHANGE order_quantity order_quantity INT DEFAULT 0 NOT NULL, CHANGE order_only_missing_parts order_only_missing_parts TINYINT(1) DEFAULT \'0\' NOT NULL, CHANGE comment comment TEXT DEFAULT NULL COLLATE utf8_unicode_ci, CHANGE name name TINYTEXT NOT NULL COLLATE utf8_unicode_ci, CHANGE last_modified last_modified DATETIME DEFAULT \'\'0000-00-00 00:00:00\'\' NOT NULL, CHANGE datetime_added datetime_added DATETIME DEFAULT \'current_timestamp()\' NOT NULL');
190
        $this->addSql('DROP INDEX idx_11074e9a727aca70 ON `devices`');
191
        $this->addSql('CREATE INDEX devices_parent_id_k ON `devices` (parent_id)');
192
        $this->addSql('ALTER TABLE `devices` ADD CONSTRAINT FK_11074E9A727ACA70 FOREIGN KEY (parent_id) REFERENCES `devices` (id)');
193
        $this->addSql('ALTER TABLE `footprints` DROP FOREIGN KEY FK_A34D68A2727ACA70');
194
        $this->addSql('ALTER TABLE `footprints` CHANGE parent_id parent_id INT DEFAULT NULL, CHANGE filename filename MEDIUMTEXT NOT NULL COLLATE utf8_unicode_ci, CHANGE filename_3d filename_3d MEDIUMTEXT NOT NULL COLLATE utf8_unicode_ci, CHANGE comment comment TEXT DEFAULT NULL COLLATE utf8_unicode_ci, CHANGE name name TINYTEXT NOT NULL COLLATE utf8_unicode_ci, CHANGE last_modified last_modified DATETIME DEFAULT \'\'0000-00-00 00:00:00\'\' NOT NULL, CHANGE datetime_added datetime_added DATETIME DEFAULT \'current_timestamp()\' NOT NULL');
195
        $this->addSql('DROP INDEX idx_a34d68a2727aca70 ON `footprints`');
196
        $this->addSql('CREATE INDEX footprints_parent_id_k ON `footprints` (parent_id)');
197
        $this->addSql('ALTER TABLE `footprints` ADD CONSTRAINT FK_A34D68A2727ACA70 FOREIGN KEY (parent_id) REFERENCES `footprints` (id)');
198
        $this->addSql('ALTER TABLE `groups` DROP FOREIGN KEY FK_F06D3970727ACA70');
199
        $this->addSql('DROP INDEX IDX_F06D3970727ACA70 ON `groups`');
200
        $this->addSql('ALTER TABLE `groups` CHANGE parent_id parent_id INT DEFAULT NULL, CHANGE comment comment MEDIUMTEXT DEFAULT NULL COLLATE utf8_general_ci, CHANGE name name VARCHAR(32) NOT NULL COLLATE utf8_general_ci, CHANGE last_modified last_modified DATETIME DEFAULT \'\'0000-00-00 00:00:00\'\' NOT NULL, CHANGE datetime_added datetime_added DATETIME DEFAULT \'current_timestamp()\' NOT NULL, CHANGE perms_labels perms_labels SMALLINT NOT NULL');
201
        $this->addSql('CREATE UNIQUE INDEX name ON `groups` (name)');
202
        $this->addSql('ALTER TABLE `manufacturers` DROP FOREIGN KEY FK_94565B12727ACA70');
203
        $this->addSql('ALTER TABLE `manufacturers` CHANGE parent_id parent_id INT DEFAULT NULL, CHANGE address address MEDIUMTEXT NOT NULL COLLATE utf8_unicode_ci, CHANGE phone_number phone_number TINYTEXT NOT NULL COLLATE utf8_unicode_ci, CHANGE fax_number fax_number TINYTEXT NOT NULL COLLATE utf8_unicode_ci, CHANGE email_address email_address TINYTEXT NOT NULL COLLATE utf8_unicode_ci, CHANGE website website TINYTEXT NOT NULL COLLATE utf8_unicode_ci, CHANGE auto_product_url auto_product_url TINYTEXT NOT NULL COLLATE utf8_unicode_ci, CHANGE comment comment TEXT DEFAULT NULL COLLATE utf8_unicode_ci, CHANGE name name TINYTEXT NOT NULL COLLATE utf8_unicode_ci, CHANGE last_modified last_modified DATETIME DEFAULT \'\'0000-00-00 00:00:00\'\' NOT NULL, CHANGE datetime_added datetime_added DATETIME DEFAULT \'current_timestamp()\' NOT NULL');
204
        $this->addSql('DROP INDEX idx_94565b12727aca70 ON `manufacturers`');
205
        $this->addSql('CREATE INDEX manufacturers_parent_id_k ON `manufacturers` (parent_id)');
206
        $this->addSql('ALTER TABLE `manufacturers` ADD CONSTRAINT FK_94565B12727ACA70 FOREIGN KEY (parent_id) REFERENCES `manufacturers` (id)');
207
        $this->addSql('ALTER TABLE `orderdetails` DROP FOREIGN KEY FK_489AFCDC4CE34BEC');
208
        $this->addSql('ALTER TABLE `orderdetails` DROP FOREIGN KEY FK_489AFCDCCBF180EB');
209
        $this->addSql('ALTER TABLE `orderdetails` DROP FOREIGN KEY FK_489AFCDC4CE34BEC');
210
        $this->addSql('ALTER TABLE `orderdetails` DROP FOREIGN KEY FK_489AFCDCCBF180EB');
211
        $this->addSql('ALTER TABLE `orderdetails` CHANGE part_id part_id INT NOT NULL, CHANGE id_supplier id_supplier INT DEFAULT 0 NOT NULL, CHANGE supplierpartnr supplierpartnr TINYTEXT NOT NULL COLLATE utf8_unicode_ci, CHANGE obsolete obsolete TINYINT(1) DEFAULT \'0\', CHANGE supplier_product_url supplier_product_url TINYTEXT NOT NULL COLLATE utf8_unicode_ci, CHANGE datetime_added datetime_added DATETIME DEFAULT \'current_timestamp()\' NOT NULL');
212
        $this->addSql('DROP INDEX idx_489afcdccbf180eb ON `orderdetails`');
213
        $this->addSql('CREATE INDEX orderdetails_id_supplier_k ON `orderdetails` (id_supplier)');
214
        $this->addSql('DROP INDEX idx_489afcdc4ce34bec ON `orderdetails`');
215
        $this->addSql('CREATE INDEX orderdetails_part_id_k ON `orderdetails` (part_id)');
216
        $this->addSql('ALTER TABLE `orderdetails` ADD CONSTRAINT FK_489AFCDC4CE34BEC FOREIGN KEY (part_id) REFERENCES `parts` (id)');
217
        $this->addSql('ALTER TABLE `orderdetails` ADD CONSTRAINT FK_489AFCDCCBF180EB FOREIGN KEY (id_supplier) REFERENCES `suppliers` (id)');
218
        $this->addSql('ALTER TABLE `parts` DROP INDEX UNIQ_6940A7FE81081E9B, ADD INDEX parts_order_orderdetails_id_k (order_orderdetails_id)');
219
        $this->addSql('ALTER TABLE `parts` DROP FOREIGN KEY FK_6940A7FE5697F554');
220
        $this->addSql('ALTER TABLE `parts` DROP FOREIGN KEY FK_6940A7FEEBBCC786');
221
        $this->addSql('DROP INDEX IDX_6940A7FEEBBCC786 ON `parts`');
222
        $this->addSql('ALTER TABLE `parts` DROP FOREIGN KEY FK_6940A7FE5697F554');
223
        $this->addSql('ALTER TABLE `parts` DROP FOREIGN KEY FK_6940A7FE7E371A10');
224
        $this->addSql('ALTER TABLE `parts` DROP FOREIGN KEY FK_6940A7FE8DF69834');
225
        $this->addSql('ALTER TABLE `parts` DROP FOREIGN KEY FK_6940A7FE1ECB93AE');
226
        $this->addSql('ALTER TABLE `parts` CHANGE id_category id_category INT DEFAULT 0 NOT NULL, CHANGE id_footprint id_footprint INT DEFAULT NULL, CHANGE id_storelocation id_storelocation INT DEFAULT NULL, CHANGE id_manufacturer id_manufacturer INT DEFAULT NULL, CHANGE id_master_picture_attachement id_master_picture_attachement INT DEFAULT NULL, CHANGE order_orderdetails_id order_orderdetails_id INT DEFAULT NULL, CHANGE datetime_added datetime_added DATETIME DEFAULT \'current_timestamp()\' NOT NULL, CHANGE last_modified last_modified DATETIME DEFAULT \'\'0000-00-00 00:00:00\'\' NOT NULL, CHANGE name name MEDIUMTEXT NOT NULL COLLATE utf8_unicode_ci, CHANGE instock instock INT DEFAULT 0 NOT NULL, CHANGE mininstock mininstock INT DEFAULT 0 NOT NULL, CHANGE favorite favorite TINYINT(1) DEFAULT \'0\' NOT NULL, CHANGE order_quantity order_quantity INT DEFAULT 1 NOT NULL, CHANGE manual_order manual_order TINYINT(1) DEFAULT \'0\' NOT NULL, CHANGE manufacturer_product_url manufacturer_product_url TINYTEXT NOT NULL COLLATE utf8_unicode_ci');
227
        $this->addSql('CREATE INDEX favorite ON `parts` (favorite)');
228
        $this->addSql('DROP INDEX idx_6940a7fe7e371a10 ON `parts`');
229
        $this->addSql('CREATE INDEX parts_id_footprint_k ON `parts` (id_footprint)');
230
        $this->addSql('DROP INDEX idx_6940a7fe1ecb93ae ON `parts`');
231
        $this->addSql('CREATE INDEX parts_id_manufacturer_k ON `parts` (id_manufacturer)');
232
        $this->addSql('DROP INDEX idx_6940a7fe5697f554 ON `parts`');
233
        $this->addSql('CREATE INDEX parts_id_category_k ON `parts` (id_category)');
234
        $this->addSql('DROP INDEX idx_6940a7fe8df69834 ON `parts`');
235
        $this->addSql('CREATE INDEX parts_id_storelocation_k ON `parts` (id_storelocation)');
236
        $this->addSql('ALTER TABLE `parts` ADD CONSTRAINT FK_6940A7FE5697F554 FOREIGN KEY (id_category) REFERENCES `categories` (id)');
237
        $this->addSql('ALTER TABLE `parts` ADD CONSTRAINT FK_6940A7FE7E371A10 FOREIGN KEY (id_footprint) REFERENCES `footprints` (id)');
238
        $this->addSql('ALTER TABLE `parts` ADD CONSTRAINT FK_6940A7FE8DF69834 FOREIGN KEY (id_storelocation) REFERENCES `storelocations` (id)');
239
        $this->addSql('ALTER TABLE `parts` ADD CONSTRAINT FK_6940A7FE1ECB93AE FOREIGN KEY (id_manufacturer) REFERENCES `manufacturers` (id)');
240
        $this->addSql('ALTER TABLE `pricedetails` DROP FOREIGN KEY FK_C68C44594A01DDC7');
241
        $this->addSql('ALTER TABLE `pricedetails` DROP FOREIGN KEY FK_C68C44594A01DDC7');
242
        $this->addSql('ALTER TABLE `pricedetails` CHANGE orderdetails_id orderdetails_id INT NOT NULL, CHANGE price price NUMERIC(11, 5) DEFAULT \'NULL\', CHANGE price_related_quantity price_related_quantity INT DEFAULT 1 NOT NULL, CHANGE min_discount_quantity min_discount_quantity INT DEFAULT 1 NOT NULL, CHANGE manual_input manual_input TINYINT(1) DEFAULT \'1\' NOT NULL, CHANGE last_modified last_modified DATETIME DEFAULT \'current_timestamp()\' NOT NULL');
243
        $this->addSql('CREATE UNIQUE INDEX pricedetails_combination_uk ON `pricedetails` (orderdetails_id, min_discount_quantity)');
244
        $this->addSql('DROP INDEX idx_c68c44594a01ddc7 ON `pricedetails`');
245
        $this->addSql('CREATE INDEX pricedetails_orderdetails_id_k ON `pricedetails` (orderdetails_id)');
246
        $this->addSql('ALTER TABLE `pricedetails` ADD CONSTRAINT FK_C68C44594A01DDC7 FOREIGN KEY (orderdetails_id) REFERENCES `orderdetails` (id)');
247
        $this->addSql('ALTER TABLE `storelocations` DROP FOREIGN KEY FK_7517020727ACA70');
248
        $this->addSql('ALTER TABLE `storelocations` CHANGE parent_id parent_id INT DEFAULT NULL, CHANGE is_full is_full TINYINT(1) DEFAULT \'0\' NOT NULL, CHANGE comment comment TEXT DEFAULT NULL COLLATE utf8_unicode_ci, CHANGE name name TINYTEXT NOT NULL COLLATE utf8_unicode_ci, CHANGE last_modified last_modified DATETIME DEFAULT \'\'0000-00-00 00:00:00\'\' NOT NULL, CHANGE datetime_added datetime_added DATETIME DEFAULT \'current_timestamp()\' NOT NULL');
249
        $this->addSql('DROP INDEX idx_7517020727aca70 ON `storelocations`');
250
        $this->addSql('CREATE INDEX storelocations_parent_id_k ON `storelocations` (parent_id)');
251
        $this->addSql('ALTER TABLE `storelocations` ADD CONSTRAINT FK_7517020727ACA70 FOREIGN KEY (parent_id) REFERENCES `storelocations` (id)');
252
        $this->addSql('ALTER TABLE `suppliers` DROP FOREIGN KEY FK_AC28B95C727ACA70');
253
        $this->addSql('ALTER TABLE `suppliers` CHANGE parent_id parent_id INT DEFAULT NULL, CHANGE address address MEDIUMTEXT NOT NULL COLLATE utf8_unicode_ci, CHANGE phone_number phone_number TINYTEXT NOT NULL COLLATE utf8_unicode_ci, CHANGE fax_number fax_number TINYTEXT NOT NULL COLLATE utf8_unicode_ci, CHANGE email_address email_address TINYTEXT NOT NULL COLLATE utf8_unicode_ci, CHANGE website website TINYTEXT NOT NULL COLLATE utf8_unicode_ci, CHANGE auto_product_url auto_product_url TINYTEXT NOT NULL COLLATE utf8_unicode_ci, CHANGE comment comment TEXT DEFAULT NULL COLLATE utf8_unicode_ci, CHANGE name name TINYTEXT NOT NULL COLLATE utf8_unicode_ci, CHANGE last_modified last_modified DATETIME DEFAULT \'\'0000-00-00 00:00:00\'\' NOT NULL, CHANGE datetime_added datetime_added DATETIME DEFAULT \'current_timestamp()\' NOT NULL');
254
        $this->addSql('DROP INDEX idx_ac28b95c727aca70 ON `suppliers`');
255
        $this->addSql('CREATE INDEX suppliers_parent_id_k ON `suppliers` (parent_id)');
256
        $this->addSql('ALTER TABLE `suppliers` ADD CONSTRAINT FK_AC28B95C727ACA70 FOREIGN KEY (parent_id) REFERENCES `suppliers` (id)');
257
        $this->addSql('ALTER TABLE `users` DROP FOREIGN KEY FK_1483A5E9FE54D947');
258
        $this->addSql('DROP INDEX IDX_1483A5E9FE54D947 ON `users`');
259
        $this->addSql('ALTER TABLE `users` CHANGE group_id group_id INT DEFAULT NULL, CHANGE name name VARCHAR(32) NOT NULL COLLATE utf8_general_ci, CHANGE password password VARCHAR(255) DEFAULT \'NULL\' COLLATE utf8_general_ci, CHANGE need_pw_change need_pw_change TINYINT(1) DEFAULT \'0\' NOT NULL, CHANGE first_name first_name TINYTEXT DEFAULT NULL COLLATE utf8_general_ci, CHANGE last_name last_name TINYTEXT DEFAULT NULL COLLATE utf8_general_ci, CHANGE department department TINYTEXT DEFAULT NULL COLLATE utf8_general_ci, CHANGE email email TINYTEXT DEFAULT NULL COLLATE utf8_general_ci, CHANGE config_language config_language TINYTEXT DEFAULT NULL COLLATE utf8_general_ci, CHANGE config_timezone config_timezone TINYTEXT DEFAULT NULL COLLATE utf8_general_ci, CHANGE config_theme config_theme TINYTEXT DEFAULT NULL COLLATE utf8_general_ci, CHANGE config_currency config_currency TINYTEXT DEFAULT NULL COLLATE utf8_general_ci, CHANGE last_modified last_modified DATETIME DEFAULT \'\'0000-00-00 00:00:00\'\' NOT NULL, CHANGE datetime_added datetime_added DATETIME DEFAULT \'current_timestamp()\' NOT NULL, CHANGE perms_labels perms_labels SMALLINT NOT NULL');
260
        $this->addSql('DROP INDEX uniq_1483a5e95e237e06 ON `users`');
261
        $this->addSql('CREATE UNIQUE INDEX name ON `users` (name)');
262
    }
263
}
264