Rev 360 | Rev 511 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 360 | Rev 386 | ||
---|---|---|---|
Line 15... | Line 15... | ||
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
16 | * See the License for the specific language governing permissions and |
16 | * See the License for the specific language governing permissions and |
17 | * limitations under the License. |
17 | * limitations under the License. |
18 | */ |
18 | */ |
19 | 19 | ||
20 | // DATABASE UPDATE 201 -> 202 |
20 | /** |
21 | // This script will be included by OIDplusDatabaseConnection.class.php inside function afterConnect(). |
21 | * This function will be called by OIDplusDatabaseConnection.class.php at method afterConnect(). |
22 | // Parameters: $this is the OIDplusDatabaseConnection class |
22 | * @param OIDplusDatabaseConnection $db is the OIDplusDatabaseConnection class |
23 | // $version is the current version (this script MUST increase the number by 1 when it is done) |
23 | * @param string $version is the current version (this script MUST increase the number by 1 when it is done) |
- | 24 | * @throws OIDplusException |
|
24 | 25 | */ |
|
25 | if (!isset($version)) throw new OIDplusException(_L('Argument "%1" is missing; was the file included in a wrong way?','version')); |
26 | function oidplus_dbupdate_201_202(OIDplusDatabaseConnection $db, string &$version) { |
26 | if (!isset($this)) throw new OIDplusException(_L('Argument "%1" is missing; was the file included in a wrong way?','this')); |
- | |
27 | - | ||
28 | if ($this->transaction_supported()) $this->transaction_begin(); |
27 | if ($db->transaction_supported()) $db->transaction_begin(); |
29 | 28 | ||
30 | // Change bit(1) types to boolean/tinyint(1) |
29 | // Change bit(1) types to boolean/tinyint(1) |
31 | if ($this->getSlang()::id() == 'pgsql') { |
30 | if ($db->getSlang()::id() == 'pgsql') { |
32 | $this->query("alter table ###config alter protected drop default"); |
31 | $db->query("alter table ###config alter protected drop default"); |
33 | $this->query("alter table ###config alter protected type boolean using get_bit(protected ,0)::boolean"); |
32 | $db->query("alter table ###config alter protected type boolean using get_bit(protected ,0)::boolean"); |
34 | $this->query("alter table ###config alter protected set default false"); |
33 | $db->query("alter table ###config alter protected set default false"); |
35 | 34 | ||
36 | $this->query("alter table ###config alter visible drop default"); |
35 | $db->query("alter table ###config alter visible drop default"); |
37 | $this->query("alter table ###config alter visible type boolean using get_bit(visible ,0)::boolean"); |
36 | $db->query("alter table ###config alter visible type boolean using get_bit(visible ,0)::boolean"); |
38 | $this->query("alter table ###config alter visible set default false"); |
37 | $db->query("alter table ###config alter visible set default false"); |
39 | 38 | ||
40 | $this->query("alter table ###asn1id alter standardized drop default"); |
39 | $db->query("alter table ###asn1id alter standardized drop default"); |
41 | $this->query("alter table ###asn1id alter standardized type boolean using get_bit(standardized,0)::boolean"); |
40 | $db->query("alter table ###asn1id alter standardized type boolean using get_bit(standardized,0)::boolean"); |
42 | $this->query("alter table ###asn1id alter standardized set default false"); |
41 | $db->query("alter table ###asn1id alter standardized set default false"); |
43 | 42 | ||
44 | $this->query("alter table ###asn1id alter well_known drop default"); |
43 | $db->query("alter table ###asn1id alter well_known drop default"); |
45 | $this->query("alter table ###asn1id alter well_known type boolean using get_bit(well_known ,0)::boolean"); |
44 | $db->query("alter table ###asn1id alter well_known type boolean using get_bit(well_known ,0)::boolean"); |
46 | $this->query("alter table ###asn1id alter well_known set default false"); |
45 | $db->query("alter table ###asn1id alter well_known set default false"); |
47 | 46 | ||
48 | $this->query("alter table ###iri alter longarc drop default"); |
47 | $db->query("alter table ###iri alter longarc drop default"); |
49 | $this->query("alter table ###iri alter longarc type boolean using get_bit(longarc ,0)::boolean"); |
48 | $db->query("alter table ###iri alter longarc type boolean using get_bit(longarc ,0)::boolean"); |
50 | $this->query("alter table ###iri alter longarc set default false"); |
49 | $db->query("alter table ###iri alter longarc set default false"); |
51 | 50 | ||
52 | $this->query("alter table ###iri alter well_known drop default"); |
51 | $db->query("alter table ###iri alter well_known drop default"); |
53 | $this->query("alter table ###iri alter well_known type boolean using get_bit(well_known ,0)::boolean"); |
52 | $db->query("alter table ###iri alter well_known type boolean using get_bit(well_known ,0)::boolean"); |
54 | $this->query("alter table ###iri alter well_known set default false"); |
53 | $db->query("alter table ###iri alter well_known set default false"); |
55 | 54 | ||
56 | $this->query("alter table ###objects alter confidential type boolean using get_bit(confidential,0)::boolean"); |
55 | $db->query("alter table ###objects alter confidential type boolean using get_bit(confidential,0)::boolean"); |
57 | 56 | ||
58 | $this->query("alter table ###ra alter privacy drop default"); |
57 | $db->query("alter table ###ra alter privacy drop default"); |
59 | $this->query("alter table ###ra alter privacy type boolean using get_bit(privacy ,0)::boolean"); |
58 | $db->query("alter table ###ra alter privacy type boolean using get_bit(privacy ,0)::boolean"); |
60 | $this->query("alter table ###ra alter privacy set default false"); |
59 | $db->query("alter table ###ra alter privacy set default false"); |
61 | } else if ($this->getSlang()::id() == 'mysql') { |
60 | } else if ($db->getSlang()::id() == 'mysql') { |
62 | $this->query("alter table ###config modify protected boolean"); |
61 | $db->query("alter table ###config modify protected boolean"); |
63 | $this->query("alter table ###config modify visible boolean"); |
62 | $db->query("alter table ###config modify visible boolean"); |
64 | $this->query("alter table ###asn1id modify standardized boolean"); |
63 | $db->query("alter table ###asn1id modify standardized boolean"); |
65 | $this->query("alter table ###asn1id modify well_known boolean"); |
64 | $db->query("alter table ###asn1id modify well_known boolean"); |
66 | $this->query("alter table ###iri modify longarc boolean"); |
65 | $db->query("alter table ###iri modify longarc boolean"); |
67 | $this->query("alter table ###iri modify well_known boolean"); |
66 | $db->query("alter table ###iri modify well_known boolean"); |
68 | $this->query("alter table ###objects modify confidential boolean"); |
67 | $db->query("alter table ###objects modify confidential boolean"); |
69 | $this->query("alter table ###ra modify privacy boolean"); |
68 | $db->query("alter table ###ra modify privacy boolean"); |
70 | } |
69 | } |
71 | 70 | ||
72 | // Rename log_user.user to log_user.username, since user is a keyword in PostgreSQL and MSSQL |
71 | // Rename log_user.user to log_user.username, since user is a keyword in PostgreSQL and MSSQL |
73 | if ($this->getSlang()::id() == 'pgsql') { |
72 | if ($db->getSlang()::id() == 'pgsql') { |
74 | $this->query("alter table ###log_user rename column \"user\" to \"username\""); |
73 | $db->query("alter table ###log_user rename column \"user\" to \"username\""); |
75 | } else if ($this->getSlang()::id() == 'mysql') { |
74 | } else if ($db->getSlang()::id() == 'mysql') { |
76 | $this->query("alter table ###log_user change `user` `username` varchar(255) NOT NULL"); |
75 | $db->query("alter table ###log_user change `user` `username` varchar(255) NOT NULL"); |
77 | } |
76 | } |
78 | 77 | ||
79 | $version = 202; |
78 | $version = 202; |
80 | $this->query("UPDATE ###config SET value = ? WHERE name = 'database_version'", array($version)); |
79 | $db->query("UPDATE ###config SET value = ? WHERE name = 'database_version'", array($version)); |
81 | 80 | ||
82 | if ($this->transaction_supported()) $this->transaction_commit(); |
- | |
83 | 81 | if ($db->transaction_supported()) $db->transaction_commit(); |
|
- | 82 | } |
|
- | 83 | ||
84 | 84 |