Skip to content

Commit

Permalink
[db] Attachments to private messages (hurtom#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
yukoff committed Aug 15, 2017
1 parent d58ea66 commit 660f45b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
9 changes: 4 additions & 5 deletions database/entities/Database/Entities/BbAttachments.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,22 @@ class BbAttachments
/**
* @var integer
*/
private $postId = '0';
private $postId;

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

private $privmsgsId = 0;

/**
* @var integer
*/
private $privmsgsId = '0';
private $userId1 = 0;

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


}
6 changes: 3 additions & 3 deletions database/mappings/Database.Entities.BbAttachments.dcm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ Database\Entities\BbAttachments:
nullable: false
options:
unsigned: true
default: '0'
default: 0
column: privmsgs_id
userId1:
type: integer
nullable: false
options:
unsigned: false
default: '0'
default: 0
column: user_id_1
userId2:
type: integer
nullable: false
options:
unsigned: false
default: '0'
default: 0
column: user_id_2
lifecycleCallbacks: { }
8 changes: 4 additions & 4 deletions database/mappings/Database.Entities.BbPrivmsgs.dcm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Database\Entities\BbPrivmsgs:
type: boolean
nullable: false
options:
default: '0'
default: 0
column: privmsgs_type
privmsgsSubject:
type: string
Expand All @@ -41,21 +41,21 @@ Database\Entities\BbPrivmsgs:
nullable: false
options:
unsigned: false
default: '0'
default: 0
column: privmsgs_from_userid
privmsgsToUserid:
type: integer
nullable: false
options:
unsigned: false
default: '0'
default: 0
column: privmsgs_to_userid
privmsgsDate:
type: integer
nullable: false
options:
unsigned: false
default: '0'
default: 0
column: privmsgs_date
privmsgsIp:
type: string
Expand Down
9 changes: 8 additions & 1 deletion database/migrations/Version20170601000000.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,18 @@ public function up(Schema $schema)
* Modify tables
******************/

// bb_attachments
/**
* bb_attachments
* @see https://github.com/hurtom/toloka/issues/27
*/
$this->addSql('DROP INDEX attach_id_post_id ON bb_attachments');
$this->addSql('DROP INDEX post_id ON bb_attachments');
$this->addSql('ALTER TABLE bb_attachments
CHANGE attach_id attach_id INT UNSIGNED NOT NULL,
CHANGE post_id post_id INT UNSIGNED NOT NULL,
CHANGE privmsgs_id privmsgs_id INT UNSIGNED DEFAULT 0 NOT NULL,
CHANGE user_id_1 user_id_1 INT DEFAULT 0 NOT NULL,
CHANGE user_id_2 user_id_2 INT DEFAULT 0 NOT NULL,
ADD PRIMARY KEY (attach_id, post_id),
ENGINE = InnoDB');

Expand Down Expand Up @@ -786,6 +792,7 @@ public function up(Schema $schema)
DROP privmsgs_enable_smilies,
DROP privmsgs_attach_sig,
DROP privmsgs_attachment,
CHANGE privmsgs_id privmsgs_id INT UNSIGNED NOT NULL,
CHANGE privmsgs_subject privmsgs_subject VARCHAR(255) DEFAULT \'0\' NOT NULL,
CHANGE privmsgs_ip privmsgs_ip VARCHAR(42) DEFAULT \'0\' NOT NULL COLLATE utf8_bin,
ENGINE = InnoDB');
Expand Down

0 comments on commit 660f45b

Please sign in to comment.