Index: cloudfront.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cloudfront/cloudfront.install,v
retrieving revision 1.2
diff -u -p -r1.2 cloudfront.install
--- cloudfront.install	31 Mar 2009 10:20:00 -0000	1.2
+++ cloudfront.install	1 Apr 2009 09:01:58 -0000
@@ -1,49 +1,54 @@
 <?php
+// $Id:
 
 /**
- * Implementation of hook_install
+ * Implementation of hook_schema()
  */
-function cloudfront_install() {
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-      $result_0 = db_query("CREATE TABLE {cloudfront_send_queue} (
-        item_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
-        bucket VARCHAR(255) NOT NULL DEFAULT '',
-        distribution_url VARCHAR(255) NOT NULL DEFAULT '',
-        imagecache_preset_id INT(10) NOT NULL DEFAULT 0,
-        inserted INT(10) NOT NULL DEFAULT 0,
-        original_file_path VARCHAR(255) NOT NULL DEFAULT '',
-        upload_file_path VARCHAR(255) NOT NULL DEFAULT '',
- 				INDEX (imagecache_preset_id, original_file_path) )
-        /*!40100 DEFAULT CHARACTER SET utf8 */
-      ");
-      $result_1 = db_query("CREATE TABLE {cloudfront_files} (
-        file_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
-        bucket VARCHAR(255) NOT NULL DEFAULT '',
-        created INT(10) NOT NULL DEFAULT 0,
-        distribution_url VARCHAR(255) NOT NULL DEFAULT '',
-        original_file_path VARCHAR(255) NOT NULL DEFAULT '',
-        imagecache_preset_id INT(10) NOT NULL DEFAULT 0, 
-				INDEX (imagecache_preset_id, original_file_path) )
-        /*!40100 DEFAULT CHARACTER SET utf8 */
-      ");
-      break;
-  }
-  
-  if ($result_0) {
-    drupal_set_message('CloudFront module was installed successfully');
-  }
-  else {
-    drupal_set_message('CloudFront module was unsuccessful. Unable to create tables.');
-  }
+function cloudfront_schema() {
+  $schema['cloudfront_send_queue'] = array(
+    'fields' => array(
+      'item_id' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
+        'bucket' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => ''),
+        'distribution_url' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => ''),
+        'imagecache_preset_id' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'),
+        'inserted' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'),
+        'original_file_path' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => ''),
+        'upload_file_path' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => '')
+      ),
+      'primary key' => array('item_id'),
+      'indexes' => array(
+        'imagecache_preset_id' => array('imagecache_preset_id', 'original_file_path')
+      ),
+  );
+
+  $schema['cloudfront_files'] = array(
+    'fields' => array(
+      'file_id' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
+      'bucket' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => ''),
+      'created' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'),
+      'distribution_url' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => ''),
+      'original_file_path' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => ''),
+      'imagecache_preset_id' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '10')
+    ),
+    'primary key' => array('file_id'),
+    'indexes' => array(
+      'imagecache_preset_id' => array('imagecache_preset_id', 'original_file_path')
+    ),
+  );
   
-  return $result_0;
+  return $schema;  
 }
 
 /**
- * Implementation of hook_uninstall
+ * Implementation of hook_install()
+ */
+function cloudfront_install() {
+  drupal_install_schema('cloudfront');
+}
+
+/**
+ * Implementation of hook_uninstall()
  */
 function cloudfront_uninstall() {
-  db_query('DROP TABLE {cloudfront_files}');
-  db_query('DROP TABLE {cloudfront_send_queue}');
-}
\ No newline at end of file
+  drupal_uninstall_schema('cloudfront');
+}
