forked from VitaliiSestrenskyi/bitrix24_migrations
-
Notifications
You must be signed in to change notification settings - Fork 1
/
createTable.php
34 lines (30 loc) · 1.14 KB
/
createTable.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
use Bitrix\Main\Application;
class migration
{
public function up()
{
$connection = Application::getInstance()->getConnection();
$sql = "CREATE TABLE test
(
ID int not null auto_increment,
ENTITY_ID INT(18) UNSIGNED not null,
ENTITY_TYPE varchar(255),
CREATED_AT datetime,
CREATED_BY varchar(255),
FILE_ID INT(18),
PRIMARY KEY (ID),
INDEX IX_TEST(ENTITY_ID, CREATED_BY, FILE_ID, ID),
CONSTRAINT `FK_ENTITY_ID` FOREIGN KEY (`ENTITY_ID`) REFERENCES `b_crm_deal` (`ID`) ON UPDATE NO ACTION ON DELETE CASCADE,
CONSTRAINT `FK_FILE_ID` FOREIGN KEY (`FILE_ID`) REFERENCES `b_file` (`ID`) ON UPDATE NO ACTION ON DELETE CASCADE
);
";
$connection->queryExecute($sql);
}
public function down()
{
$connection = Application::getInstance()->getConnection();
$sql = "drop table if exists test;";
$connection->queryExecute($sql);
}
}