Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
ae72ad34
Commit
ae72ad34
authored
Jun 30, 2007
by
Donal McMullan
Browse files
Harmonising the install and upgrade databases
parent
c56b5ebb
Changes
5
Hide whitespace changes
Inline
Side-by-side
htdocs/auth/internal/db/install.xml
deleted
100644 → 0
View file @
c56b5ebb
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB
PATH=
"lib/db"
VERSION=
"20061127"
COMMENT=
"XMLDB file for Mahara's blog-related tables"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation=
"../../../lib/xmldb/xmldb.xsd"
>
<STATEMENTS>
<STATEMENT
NAME=
"insert auth_instance"
TYPE=
"insert"
TABLE=
"auth_instance"
>
<SENTENCES>
<SENTENCE
TEXT=
"(instancename, priority, institution, authname) VALUES ('internal', 1, 'mahara','internal')"
/>
</SENTENCES>
</STATEMENT>
</XMLDB>
htdocs/auth/internal/db/upgrade.php
View file @
ae72ad34
<?php
function
xmldb_auth_internal_upgrade
(
$oldversion
=
0
)
{
if
(
$oldversion
<
2007062900
)
{
$record
=
new
stdClass
();
$record
->
instancename
=
'internal'
;
$record
->
priority
=
'1'
;
$record
->
institution
=
'mahara'
;
$record
->
authname
=
'internal'
;
return
insert_record
(
'auth_instance'
,
$record
);
$prefix
=
get_config
(
'dbprefix'
);
$auth_instance
=
new
stdClass
();
$auth_instance
->
instancename
=
'internal'
;
$auth_instance
->
priority
=
'1'
;
$auth_instance
->
institution
=
'mahara'
;
$auth_instance
->
authname
=
'internal'
;
$auth_instance
->
id
=
insert_record
(
'auth_instance'
,
$auth_instance
,
'id'
,
true
);
if
(
!
empty
(
$auth_instance
->
id
))
{
return
execute_sql
(
"UPDATE
{
$prefix
}
usr set authinstance='
{
$auth_instance
->
id
}
'"
);
}
return
false
;
}
return
true
;
...
...
htdocs/lib/db/install.xml
View file @
ae72ad34
...
...
@@ -16,7 +16,7 @@
</TABLE>
<TABLE
NAME=
"auth_installed"
>
<FIELDS>
<FIELD
NAME=
"name"
TYPE=
"char"
LENGTH=
"
100
"
NOTNULL=
"true"
/>
<FIELD
NAME=
"name"
TYPE=
"char"
LENGTH=
"
255
"
NOTNULL=
"true"
/>
<FIELD
NAME=
"version"
TYPE=
"int"
LENGTH=
"10"
NOTNULL=
"true"
/>
<FIELD
NAME=
"release"
TYPE=
"text"
LENGTH=
"small"
NOTNULL=
"true"
/>
<FIELD
NAME=
"active"
TYPE=
"int"
LENGTH=
"1"
NOTNULL=
"true"
DEFAULT=
"1"
/>
...
...
@@ -63,11 +63,7 @@
<KEYS>
<KEY
NAME=
"primary"
TYPE=
"primary"
FIELDS=
"id"
/>
<KEY
NAME=
"authnamefk"
TYPE=
"foreign"
FIELDS=
"authname"
REFTABLE=
"auth_installed"
REFFIELDS=
"name"
/>
<!-- The following foreign-key constraint can't be implemented, as we currently have to be able to create
the auth instance before we create the institution record. This workflow is probably bogus and should
be changed once we're able to do multi-page/tabbed forms.
<KEY
NAME=
"institutionfk"
TYPE=
"foreign"
FIELDS=
"institution"
REFTABLE=
"institution"
REFFIELDS=
"name"
/>
-->
</KEYS>
</TABLE>
<TABLE
NAME=
"institution_locked_profile_field"
>
...
...
@@ -112,7 +108,7 @@
<FIELD
NAME=
"quotaused"
TYPE=
"int"
LENGTH=
"10"
NOTNULL=
"true"
DEFAULT=
"0"
/>
<FIELD
NAME=
"authinstance"
TYPE=
"int"
LENGTH=
"10"
NOTNULL=
"true"
DEFAULT=
"1"
/>
<FIELD
NAME=
"sessionid"
TYPE=
"char"
LENGTH=
"32"
NOTNULL=
"false"
DEFAULT=
""
/>
<FIELD
NAME=
"lastauthinstance"
TYPE=
"int"
LENGTH=
"1"
NOTNULL=
"false"
DEFAULT=
"NULL"
/>
<FIELD
NAME=
"lastauthinstance"
TYPE=
"int"
LENGTH=
"1
0
"
NOTNULL=
"false"
DEFAULT=
"NULL"
/>
</FIELDS>
<KEYS>
<KEY
NAME=
"primary"
TYPE=
"primary"
FIELDS=
"id"
/>
...
...
@@ -135,7 +131,7 @@
<FIELD
NAME=
"sessionid"
TYPE=
"char"
LENGTH=
"40"
NOTNULL=
"true"
/>
</FIELDS>
<KEYS>
<KEY
NAME=
"primary"
TYPE=
"primary"
FIELDS=
"userid"
/>
<KEY
NAME=
"primary"
TYPE=
"primary"
FIELDS=
"userid
,instanceid
"
/>
<!-- <KEY NAME="userfk" TYPE="foreign" FIELDS="userid,username" REFTABLE="usr" REFFIELDS="userid,username" /> -->
</KEYS>
</TABLE>
...
...
htdocs/lib/db/upgrade.php
View file @
ae72ad34
...
...
@@ -295,7 +295,7 @@ function xmldb_core_upgrade($oldversion=0) {
$table
=
new
XMLDBTable
(
'auth_instance'
);
$table
->
addFieldInfo
(
'id'
,
XMLDB_TYPE_INTEGER
,
'10'
,
XMLDB_UNSIGNED
,
XMLDB_NOTNULL
,
XMLDB_SEQUENCE
);
$table
->
addFieldInfo
(
'instancename'
,
XMLDB_TYPE_CHAR
,
'255'
,
null
,
XMLDB_NOTNULL
);
$table
->
addFieldInfo
(
'priority'
,
XMLDB_TYPE_INTEGER
,
'2'
,
XMLDB_UNSIGNED
,
XMLDB_NOTNULL
);
$table
->
addFieldInfo
(
'priority'
,
XMLDB_TYPE_INTEGER
,
'2'
,
XMLDB_UNSIGNED
,
XMLDB_NOTNULL
,
null
,
null
,
null
,
0
);
$table
->
addFieldInfo
(
'institution'
,
XMLDB_TYPE_CHAR
,
'255'
,
null
,
XMLDB_NOTNULL
);
$table
->
addFieldInfo
(
'authname'
,
XMLDB_TYPE_CHAR
,
'255'
,
null
,
XMLDB_NOTNULL
);
$table
->
addKeyInfo
(
'primary'
,
XMLDB_KEY_PRIMARY
,
array
(
'id'
));
...
...
@@ -326,10 +326,10 @@ function xmldb_core_upgrade($oldversion=0) {
$table
->
addFieldInfo
(
'ipaddress'
,
XMLDB_TYPE_CHAR
,
'39'
,
null
,
XMLDB_NOTNULL
);
$table
->
addFieldInfo
(
'portno'
,
XMLDB_TYPE_INTEGER
,
'3'
,
XMLDB_UNSIGNED
,
XMLDB_NOTNULL
,
null
,
null
,
null
,
80
);
$table
->
addFieldInfo
(
'appname'
,
XMLDB_TYPE_CHAR
,
'20'
,
null
,
XMLDB_NOTNULL
);
$table
->
addFieldInfo
(
'publickey'
,
XMLDB_TYPE_TEXT
,
null
,
null
,
XMLDB_NOTNULL
);
$table
->
addFieldInfo
(
'publickey'
,
XMLDB_TYPE_TEXT
,
null
,
null
,
XMLDB_NOTNULL
,
null
,
null
,
null
,
''
);
$table
->
addFieldInfo
(
'publickeyexpires'
,
XMLDB_TYPE_INTEGER
,
'10'
,
XMLDB_UNSIGNED
,
XMLDB_NOTNULL
);
$table
->
addFieldInfo
(
'deleted'
,
XMLDB_TYPE_INTEGER
,
'1'
,
XMLDB_UNSIGNED
,
XMLDB_NOTNULL
);
$table
->
addFieldInfo
(
'lastconnecttime'
,
XMLDB_TYPE_INTEGER
,
'10'
,
XMLDB_UNSIGNED
,
XMLDB_NOTNULL
);
$table
->
addFieldInfo
(
'deleted'
,
XMLDB_TYPE_INTEGER
,
'1'
,
XMLDB_UNSIGNED
,
XMLDB_NOTNULL
,
null
,
null
,
null
,
0
);
$table
->
addFieldInfo
(
'lastconnecttime'
,
XMLDB_TYPE_INTEGER
,
'10'
,
XMLDB_UNSIGNED
,
XMLDB_NOTNULL
,
null
,
null
,
null
,
0
);
$table
->
addKeyInfo
(
'primary'
,
XMLDB_KEY_PRIMARY
,
array
(
'wwwroot'
));
create_table
(
$table
);
...
...
@@ -362,11 +362,6 @@ function xmldb_core_upgrade($oldversion=0) {
$table
->
addKeyInfo
(
'primary'
,
XMLDB_KEY_PRIMARY
,
array
(
'userid'
,
'instanceid'
));
create_table
(
$table
);
//$table = new XMLDBTable('sso_session');
//$key = new XMLDBKey("userfk");
//$key->setAttributes(XMLDB_KEY_FOREIGN, array('userid','username'), 'usr', array('id','username'));
//add_key($table, $key);
$table
=
new
XMLDBTable
(
'usr'
);
$field
=
new
XMLDBField
(
'authinstance'
);
$field
->
setAttributes
(
XMLDB_TYPE_INTEGER
,
10
,
XMLDB_UNSIGNED
,
XMLDB_NOTNULL
,
null
,
null
,
null
,
1
);
...
...
@@ -380,7 +375,7 @@ function xmldb_core_upgrade($oldversion=0) {
add_index
(
$table
,
$index
);
$field
=
new
XMLDBField
(
'sessionid'
);
$field
->
setAttributes
(
XMLDB_TYPE_CHAR
,
32
);
$field
->
setAttributes
(
XMLDB_TYPE_CHAR
,
32
,
null
,
null
,
null
,
null
,
null
,
''
);
add_field
(
$table
,
$field
);
$field
=
new
XMLDBField
(
'lastauthinstance'
);
...
...
htdocs/lib/upgrade.php
View file @
ae72ad34
...
...
@@ -459,10 +459,11 @@ function core_install_defaults() {
$auth_instance
=
new
StdClass
;
$auth_instance
->
instancename
=
'internal'
;
$auth_instance
->
priority
=
'1'
;
$auth_instance
->
institution
=
'mahara'
;
$auth_instance
->
authname
=
'internal'
;
insert_record
(
'auth_instance'
,
$auth_instance
);
$auth_instance
->
id
=
insert_record
(
'auth_instance'
,
$auth_instance
,
'id'
,
true
);
// Insert the root user
$user
=
new
StdClass
;
$user
->
id
=
0
;
...
...
@@ -481,6 +482,7 @@ function core_install_defaults() {
$user
->
username
=
'admin'
;
$user
->
password
=
'mahara'
;
$user
->
institution
=
'mahara'
;
$user
->
authinstance
=
$auth_instance
->
id
;
$user
->
passwordchange
=
1
;
$user
->
admin
=
1
;
$user
->
firstname
=
'Admin'
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment