ここの情報は古いです。ご理解頂いた上でお取り扱いください。
Line | |
---|
1 | <?php |
---|
2 | |
---|
3 | /** |
---|
4 | * This file is part of the OpenPNE package. |
---|
5 | * (c) OpenPNE Project (http://www.openpne.jp/) |
---|
6 | * |
---|
7 | * For the full copyright and license information, please view the LICENSE |
---|
8 | * file and the NOTICE file that were distributed with this source code. |
---|
9 | */ |
---|
10 | |
---|
11 | class initialize extends opMigration |
---|
12 | { |
---|
13 | public function up() |
---|
14 | { |
---|
15 | try |
---|
16 | { |
---|
17 | $conn = Doctrine_Manager::connection(); |
---|
18 | |
---|
19 | $conn->export->alterTable('member', array('add' => array( |
---|
20 | 'invite_member_id' => array( |
---|
21 | 'type' => 'integer', |
---|
22 | 'size' => 11, |
---|
23 | ), |
---|
24 | ))); |
---|
25 | |
---|
26 | $conn->export->createForeignKey('member', array( |
---|
27 | 'name' => 'member_FI_1', |
---|
28 | 'local' => 'invite_member_id', |
---|
29 | 'foreign' => 'id', |
---|
30 | 'foreignTable' => 'member', |
---|
31 | 'onDelete' => 'SET NULL' |
---|
32 | )); |
---|
33 | } |
---|
34 | catch (Doctrine_Connection_Exception $e) |
---|
35 | { |
---|
36 | // FIXME: this script should check only "column already exists" error. |
---|
37 | $syntaxErrorCode = 42; |
---|
38 | |
---|
39 | // do nothing when the error is "already exists" because it is caused the following reasons: |
---|
40 | // * the SNS has been created or rebuilt on since 3.0.1 |
---|
41 | // * the "openpne:update" task has been executed |
---|
42 | if ($e->getCode() != $syntaxErrorCode) |
---|
43 | { |
---|
44 | throw $e; |
---|
45 | } |
---|
46 | } |
---|
47 | } |
---|
48 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.
Download in other formats: