Skip to content

Commit

Permalink
[db] Keep the bb_bt_users_dl_status table during migration (hurtom#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
yukoff committed Aug 8, 2017
1 parent a164f16 commit fdf5e9d
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 9 deletions.
42 changes: 42 additions & 0 deletions database/entities/Database/Entities/BbBtUsersDlStatus.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace Database\Entities;

/**
* BbBtUsersDlStatus
*/
class BbBtUsersDlStatus
{
/**
* @var integer
*/
private $topicId;

/**
* @var integer
*/
private $userId;

/**
* @var integer
*/
private $userStatus = '0';

/**
* @var integer
*/
private $complCount = '0';

/**
* @var integer
*/
private $updateTime = '0';

/**
* @var boolean
*/
private $dropRelease = '0';


}

48 changes: 48 additions & 0 deletions database/mappings/Database.Entities.BbBtUsersDlStatus.dcm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
Database\Entities\BbBtUsersDlStatus:
type: entity
table: bb_bt_users_dl_status
options:
charset: utf8mb4
collate: utf8mb4_unicode_ci
id:
topicId:
type: integer
nullable: false
options:
unsigned: true
id: true
column: topic_id
userId:
type: integer
nullable: false
options:
unsigned: false
id: true
column: user_id
fields:
userStatus:
type: smallint
nullable: false
options:
default: '0'
column: user_status
complCount:
type: smallint
nullable: false
options:
default: '0'
column: compl_count
updateTime:
type: integer
nullable: false
options:
unsigned: false
default: '0'
column: update_time
dropRelease:
type: boolean
nullable: false
options:
default: '0'
column: drop_release
lifecycleCallbacks: { }
34 changes: 25 additions & 9 deletions database/migrations/Version20170601000000.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public function up(Schema $schema)
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');

/*
* add new tables
*/
/******************
* Add new tables
******************/

// bb_ads
$this->addSql('CREATE TABLE bb_ads (
Expand Down Expand Up @@ -257,6 +257,10 @@ public function up(Schema $schema)
PRIMARY KEY(topic_id)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');

/******************
* Drop old tables
******************/

/**
* bb_bt_config
* @see https://github.com/hurtom/toloka/issues/95
Expand All @@ -275,8 +279,6 @@ public function up(Schema $schema)
*/
$this->addSql('DROP TABLE bb_bt_torrents_del');

$this->addSql('DROP TABLE bb_bt_users_dl_status');

/**
* bb_confirm
* @see https://github.com/hurtom/toloka/issues/98
Expand Down Expand Up @@ -345,9 +347,9 @@ public function up(Schema $schema)
*/
$this->addSql('DROP TABLE bb_topics_move');

/*
* modify tables
*/
/******************
* Modify tables
******************/

// bb_attachments
$this->addSql('DROP INDEX attach_id_post_id ON bb_attachments');
Expand Down Expand Up @@ -662,7 +664,21 @@ public function up(Schema $schema)
$this->addSql('CREATE INDEX topic_id ON bb_posts (topic_id)');
$this->addSql('CREATE INDEX forum_id_post_time ON bb_posts (forum_id, post_time)');

// bb_posts_edit
/**
* bb_bt_users_dl_status
* @see https://github.com/hurtom/toloka/issues/97
*/
$this->addSql('ALTER TABLE bb_bt_users_dl_status
CHANGE topic_id topic_id INT UNSIGNED NOT NULL,
CHANGE user_id user_id INT NOT NULL,
CHANGE user_status user_status SMALLINT DEFAULT 0 NOT NULL,
CHANGE compl_count compl_count SMALLINT DEFAULT 0 NOT NULL,
ENGINE=InnoDB ROW_FORMAT=DEFAULT');

/**
* bb_posts_edit
* @see https://github.com/hurtom/toloka/issues/40
*/
$this->addSql('ALTER TABLE bb_posts_edit
CHANGE post_id post_id INT UNSIGNED NOT NULL,
ADD PRIMARY KEY (post_id),
Expand Down

0 comments on commit fdf5e9d

Please sign in to comment.