[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: www/cms/drupal5/modules/akademy
From: Niels van Mourik <niels () shodan ! nl>
Date: 2008-04-06 20:58:06
Message-ID: 1207515486.052611.17300.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 794188 by nielsvm:
Checkin of a patch from Marijn Kruisselbrink:
Marijn wrote the following database tables:
- akademy_registrant_day
- akademy_registrant_option
- akademy_day
- akademy_accommodation
- akademy_accommodation_day
- akademy_option
So now we have our datamodel in place. I've added uninstall code and removed a few \
typos...
CCMAIL:m.kruisselbrink@student.tue.nl
CCMAIL:bart.cerneels@kde.org
M +110 -3 akademy.install
--- trunk/www/cms/drupal5/modules/akademy/akademy.install #794187:794188
@@ -57,13 +57,102 @@
"`remaining` varchar(255) NOT NULL COMMENT 'Remaining information field', \
".
"`mac_wired` varchar(255) NOT NULL COMMENT 'Mac address of wired devices', \
".
"`mac_wireless` varchar(255) NOT NULL COMMENT 'Mac address of your \
wireless device', ".
- "KEY `uid` (`uid`) ".
+ "PRIMARY KEY `uid` (`uid`) ".
") ENGINE=MyISAM DEFAULT CHARSET=utf8;"
);
//Add the admin user to the registrations table
db_query("INSERT INTO {akademy_registrant} (uid, name, locked, nick, birth) \
VALUES (1, '%s', 0, '%s', '%s')", t('Administrator'), t('admin'), date('c') ); +
+ //Table containing info about the accommodation and attendance of each \
registrant + db_query(
+ "CREATE TABLE IF NOT EXISTS {akademy_registrant_day} ( ".
+ "`uid` INT(11) NOT NULL COMMENT 'The user ID', ".
+ "`dayid` INT(11) NOT NULL COMMENT 'The day ID', ".
+ "`attends` TINYINT(1) NOT NULL COMMENT 'Does the registrant attend this \
day? 1 for yes, 0 for no', ". + "`accommodationid` INT(11) NOT NULL COMMENT \
'Optionally the ID of the accommodation being used on this day/night, 0 if no Akademy \
provided accommodation is required for this night', ". + "PRIMARY KEY \
(`uid`, `dayid`) ". + ") ENGINE=MyISAM DEFAULT CHARSET=utf8;"
+ );
+
+ // Table containing info about the options a user ordered during registration
+ db_query(
+ "CREATE TABLE IF NOT EXISTS {akademy_registrant_option} ( ".
+ "`uid` INT(11) NOT NULL COMMENT 'The user ID', ".
+ "`optionid` INT(11) NOT NULL COMMENT 'The option ID', ".
+ "`count` INT(11) NOT NULL COMMENT 'How many times is this option \
ordered, right now probably always 1', ". + "PRIMARY KEY (`uid`, `optionid`) \
". + ") ENGINE=MyISAM DEFAULT CHARSET=utf8;"
+ );
+
+ //Table containing info about the days at Akademy
+ db_query(
+ "CREATE TABLE IF NOT EXISTS {akademy_day} ( ".
+ "`dayid` INT(11) NOT NULL AUTO_INCREMENT COMMENT 'The Day ID', ".
+ "`daydate` DATE NOT NULL COMMENT 'The date of this day', ".
+ "`description` VARCHAR(255) NOT NULL COMMENT 'A short description of \
this day', ". + "PRIMARY KEY (`dayid`) ".
+ ") ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='List of days of Akademy' \
AUTO_INCREMENT=1;" + );
+
+ //Add the days of Akademy 2008
+ db_query("INSERT INTO {akademy_day} (dayid, daydate, description) VALUES (%d, \
'%s', '%s')", 1, '2008-08-01', 'Conference day 1'); + db_query("INSERT INTO \
{akademy_day} (dayid, daydate, description) VALUES (%d, '%s', '%s')", 2, \
'2008-08-01', 'Conference day 2'); + db_query("INSERT INTO {akademy_day} (dayid, \
daydate, description) VALUES (%d, '%s', '%s')", 3, '2008-08-01', 'eV meeting'); + \
db_query("INSERT INTO {akademy_day} (dayid, daydate, description) VALUES (%d, '%s', \
'%s')", 4, '2008-08-01', 'hacking'); + db_query("INSERT INTO {akademy_day} \
(dayid, daydate, description) VALUES (%d, '%s', '%s')", 5, '2008-08-01', 'hacking'); \
+ db_query("INSERT INTO {akademy_day} (dayid, daydate, description) VALUES (%d, \
'%s', '%s')", 6, '2008-08-01', 'hacking'); + db_query("INSERT INTO {akademy_day} \
(dayid, daydate, description) VALUES (%d, '%s', '%s')", 7, '2008-08-01', 'hacking, \
day trip'); +
+ //Create the accommodation table
+ db_query(
+ "CREATE TABLE IF NOT EXISTS {akademy_accommodation} ( ".
+ "`accommodationid` INT(11) NOT NULL AUTO_INCREMENT COMMENT 'The \
Accommodation ID', ". + "`name` VARCHAR(255) NOT NULL COMMENT 'The name of \
this accommodation', ". + "`description` VARCHAR(255) NOT NULL COMMENT 'A \
short description of this accommodation', ". + "`pricepernight` INT(11) \
NOT NULL COMMENT 'The price of this accommodation per night (in euro-cents)', ". + \
"PRIMARY KEY (`accommodationid`) ". + ") ENGINE=MyISAM DEFAULT CHARSET=utf8 \
COMMENT='List of accommodation options' AUTO_INCREMENT=1 ;" + );
+
+ //Add the accommodation options of Akademy 2008
+ db_query("INSERT INTO {akademy_accommodation} (accommodationid, name, \
description, pricepernight) VALUES (%d, '%s', '%s', %d)", + 1, \
"Zandpoort", "Late night hacking", 1234); + db_query("INSERT INTO \
{akademy_accommodation} (accommodationid, name, description, pricepernight) VALUES \
(%d, '%s', '%s', %d)", + 2, "Andere", "Late night socializing", 2143);
+
+ //Create the accommodation_day table
+ db_query(
+ "CREATE TABLE IF NOT EXISTS {akademy_accommodation_day} ( ".
+ "`accommodationid` INT(11) NOT NULL COMMENT 'The accommodation ID', ".
+ "`dayid` INT(11) NOT NULL COMMENT 'The day ID', ".
+ "`totalplaces` INT(11) NOT NULL COMMENT 'The total number of places \
available for this accommodation on this day', ". + "PRIMARY KEY \
(`accommodationid`, `dayid`) ". + ") ENGINE=MyISAM DEFAULT CHARSET=utf8 \
COMMENT='Availability of accommodations on days';" + );
+ //Add the availability data for Akademy 2008
+ for ($day = 1; $day <= 6; $day++)
+ db_query("INSERT INTO {akademy_accommodation_day} (accommodationid, dayid, \
totalplaces) VALUES (%d, %d, %d)", 1, $day, 44); + for ($day = 2; $day <= 7; \
$day++) + db_query("INSERT INTO {akademy_accommodation_day} (accommodationid, \
dayid, totalplaces) VALUES (%d, %d, %d)", 2, $day, 60); +
+ //Create the option table
+ db_query(
+ "CREATE TABLE IF NOT EXISTS {akademy_option} ( ".
+ "`optionid` INT(11) NOT NULL AUTO_INCREMENT COMMENT 'The option ID', ".
+ "`name` VARCHAR(255) NOT NULL COMMENT 'A short name for this option', ".
+ "`description` VARCHAR(255) NOT NULL COMMENT 'A longer description for \
this option', ". + "`price` INT(11) NOT NULL COMMENT 'The price of this \
option (in euro-cents)', ". + "`totalavailability` INT(11) NOT NULL \
COMMENT 'The total number of times this item can be sold, some high number if it is \
unlimited', ". + "PRIMARY KEY (`optionid`) ".
+ ") ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Optional items someone may \
book together with his/her akademy registration' AUTO_INCREMENT=1 ;" + );
+
+ //Add the options for Akademy 2008
+ db_query("INSERT INTO {akademy_option} (name, description, price, \
totalavailability) VALUES ('%s', '%s', %d, %d)", "Social event", "Social event on day \
X", 1000, 150); + db_query("INSERT INTO {akademy_option} (name, description, \
price, totalavailability) VALUES ('%s', '%s', %d, %d)", "Day trip", "Day trip on day \
X", 0, 2000000000); +
//Our country table
db_query(
"CREATE TABLE IF NOT EXISTS {akademy_country} ( ".
@@ -317,11 +406,29 @@
db_query("INSERT INTO {akademy_country} (iso, name, country, iso3, numcode) \
VALUES ('YE','YEMEN','Yemen','YEM','887');");
db_query("INSERT INTO {akademy_country} (iso, name, country, iso3, numcode) \
VALUES ('ZM','ZAMBIA','Zambia','ZMB','894');");
db_query("INSERT INTO {akademy_country} (iso, name, country, iso3, numcode) \
VALUES ('ZW','ZIMBABWE','Zimbabwe','ZWE','716');");
-
break;
case 'pgsql':
drupal_set_message(t("Unfortunately there are no PostGreSQL database schemes \
available. Please help improve this module."), 'error'); break;
}
-}
\ No newline at end of file
+}
+
+/**
+ * Implementation of hook_install()
+ *
+ * @ingroup hook-implementations
+ */
+function akademy_uninstall() {
+ variable_del('akademy_registration_locked');
+ db_query("DROP TABLE {akademy_registrant};");
+ db_query("DROP TABLE {akademy_registrant_day};");
+ db_query("DROP TABLE {akademy_registrant_option};");
+ db_query("DROP TABLE {akademy_day};");
+ db_query("DROP TABLE {akademy_accommodation};");
+ db_query("DROP TABLE {akademy_accommodation_day};");
+ db_query("DROP TABLE {akademy_option};");
+ db_query("DROP TABLE {akademy_country};");
+}
+
+// DROP TABLE `akademy_accommodation`, `akademy_accommodation_day`, \
`akademy_country`, `akademy_day`, `akademy_option`, `akademy_registrant`, \
`akademy_registrant_day`, `akademy_registrant_option`;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic