/[drupal]/contributions/modules/cdn2/cdn2.install
ViewVC logotype

Contents of /contributions/modules/cdn2/cdn2.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.5 - (show annotations) (download) (as text)
Sun Mar 22 17:12:19 2009 UTC (8 months ago) by ocyrus
Branch: MAIN
CVS Tags: HEAD
Changes since 1.4: +27 -142 lines
File MIME type: text/x-php
Mistake on merge
1 <?php
2 // $Id: cdn2.install,v 1.4 2009/03/22 05:44:25 ocyrus Exp $
3
4 function cdn2_install() {
5 switch ($GLOBALS['db_type']) {
6 case 'mysql':
7 case 'mysqli':
8 $sql = array();
9 $sql[] = "CREATE TABLE {cdn2_videos} (
10 `id` INT NOT NULL,
11 `nid` INT NOT NULL ,
12 `video_token` VARCHAR( 36 ) NOT NULL ,
13 `preset_name` VARCHAR( 50 ) NOT NULL ,
14 `status` VARCHAR( 20 ) NOT NULL ,
15 `asset_fetch_url` TEXT NOT NULL ,
16 `file_size` VARCHAR( 50 ) ,
17 `video_length` VARCHAR( 50 ) ,
18 PRIMARY KEY ( `id` )
19 ) ENGINE = MYISAM ";
20
21 $sql[] = "CREATE TABLE {cdn2_video_node} (
22 `vid` INT NOT NULL ,
23 `nid` INT NOT NULL DEFAULT 0 ,
24 `video_token` VARCHAR( 36 ) NOT NULL ,
25 `is_submitted` TINYINT( 1 ) NOT NULL DEFAULT '0',
26 PRIMARY KEY ( `vid` )
27 ) ENGINE = MYISAM ";
28
29 foreach ($sql as $query) {
30 db_query($query);
31 }
32 }
33 }
34
35 #################################################
36 # New Rule: all database update
37 # scripts must be idempotent: this means
38 # they will either make the suggested change
39 # or do no harm.
40 # Example of NOT idempotent: create an update
41 # that adds a column, then also add that column
42 # to the original install script: this will work
43 # for existing users and break new users.
44 # Fix to be idempotent: check whether the column
45 # exists before adding it. This will unbreak new
46 # users.
47 #################################################
48
49 # This update function was created for a client who had cdn2_install()
50 # fail to install properly, and was missing this table.
51 function cdn2_update_5() {
52 $items = array();
53 $items[] = update_sql("CREATE TABLE if not exists {cdn2_video_node} (
54 `vid` INT NOT NULL ,
55 `nid` INT NOT NULL DEFAULT 0 ,
56 `video_token` VARCHAR( 36 ) NOT NULL ,
57 `is_submitted` TINYINT( 1 ) NOT NULL DEFAULT '0',
58 PRIMARY KEY ( `vid` )
59 ) ENGINE = MYISAM ;");
60 return $items;
61 }
62
63 # Adds the is_submitted column, for clients that installed a previous version of cdn2_install
64 # that lacked this.
65 function cdn2_update_6() {
66 $items = array();
67 $items[] = update_sql("
68 if not exists (select * from syscolumns
69 where id=object_id('cdn2_video_node') and name='is_submitted')
70 ALTER TABLE {cdn2_video_node} ADD is_submitted TINYINT( 1 ) NOT NULL DEFAULT '0'
71 ");
72 return $items;
73 }
74
75 # The update function recreates the cdn2_videos table for a client who accidentally
76 # manually deleted it.
77 function cdn2_update_7() {
78 $items = array();
79 $items[] = update_sql("CREATE TABLE if not exists {cdn2_videos} (
80 `id` INT NOT NULL,
81 `nid` INT NOT NULL ,
82 `video_token` VARCHAR( 36 ) NOT NULL ,
83 `preset_name` VARCHAR( 50 ) NOT NULL ,
84 `status` VARCHAR( 20 ) NOT NULL ,
85 `asset_fetch_url` TEXT NOT NULL ,
86 `file_size` VARCHAR( 50 ) ,
87 `video_length` VARCHAR( 50 ) ,
88 PRIMARY KEY ( `id` )
89 ) ENGINE = MYISAM ;");
90 return $items;
91 }

  ViewVC Help
Powered by ViewVC 1.1.2