aboutsummaryrefslogtreecommitdiff
path: root/modules/video_zencoder/video_zencoder.install
blob: 513ebe13a60bae1d9b75ebe878b2915e77ba0aa5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php


/**
 * @file
 * Provides installation functions for video_s3.module.
 */

/**
 * Implementation of hook_schema().
 */
function video_zencoder_schema() {
  $schema['video_zencoder'] = array(
    'description' => t('Store video s3 cdn and convert with zencoder webservice'),
    'fields' => array(
      'vid' => array(
        'description' => t('Auto Increment id'),
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'fid' => array(
        'description' => t('Original file id'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'nid' => array(
        'description' => t('Node id'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'jobid' => array(
        'description' => t('Job id'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'status' => array(
        'description' => t('Status of the cdn transfer'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'dimensions' => array(
        'type' => 'varchar',
        'length' => '255',
        'default' => '',
        'description' => t('The dimensions of the video.'),
      ),
      'completed' => array(
        'description' => t('Time of successful completion to amazon.'),
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'data' => array(
        'type' => 'text',
        'not null' => FALSE,
        'size' => 'big',
        'description' => 'A serialized array of converted files. Use of this field is discouraged and it will likely disappear in a future version of Drupal.',
      ),
    ),
    'indexes' => array(
      'status' => array('status'),
      'file' => array('fid'),
    ),
    'primary key' => array('vid'),
  );
  return $schema;
}

/**
 * Implementation of hook_install().
 */
function video_zencoder_install() {
  drupal_install_schema('video_zencoder');
  // set the module weight to low since we need this to load later time than in S3
  db_query("UPDATE {system} SET weight = 50 WHERE name = 'video_zencoder'");
}

/**
 * Implementation of hook_uninstall().
 */
function video_zencoder_uninstall() {
  drupal_uninstall_schema('video_zencoder');
  // TODO : Delete our variables.
}

// ALTER TABLE `video_zencoder` ADD `dimensions` VARCHAR( 255 ) NULL AFTER `filesize` ;
/**
 * Update 6401
 * Adding new dimentaion row to the table
 * @return <type>
 */
function video_zencoder_update_6401() {
  $ret = array();
  // set settings column to accept larger values
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql('ALTER TABLE {video_zencoder} ADD dimensions VARCHAR( 255 ) NULL NULL AFTER filesize');
      break;

    case 'pgsql':
      db_add_column($ret, 'video_zencoder', 'dimensions', 'VARCHAR', array('null' => TRUE));
      break;
  }

  return $ret;
}

/**
 * Update 6402
 * Adding data field and remove unwanted fields from the table
 * @return <type>
 */
function video_zencoder_update_6402() {
  $ret = array();
  // drop un wanted fields in video zencoder
  db_drop_field($ret, 'video_zencoder', 'filesize');
  db_drop_field($ret, 'video_zencoder', 'outputid');
  db_drop_field($ret, 'video_zencoder', 'bucket');
  db_drop_field($ret, 'video_zencoder', 'filename');
  db_drop_field($ret, 'video_zencoder', 'filepath');
  db_drop_field($ret, 'video_zencoder', 'filemime');
  db_add_column($ret, 'video_zencoder', 'data', 'longtext', array('null' => TRUE));
  return $ret;
}