Ticket #1792: sqlite3-support.dpatch

File sqlite3-support.dpatch, 2.9 kB (added by diego_iastrubni, 2 years ago)

sqlite3 support

Line 
1 #! /bin/sh /usr/share/dpatch/dpatch-run
2 ## sqlite3-support.dpatch by Diego Iastrubni <diego.iastrubni@xorcom.com>
3 ##
4 ## DP: SQLite3 support. Fixes upstream http://freepbx.org/trac/ticket/1776
5
6 @DPATCH@
7 diff -urNad freepbx-module-ivr~/install.php freepbx-module-ivr/install.php
8 --- freepbx-module-ivr~/install.php     2007-02-10 00:34:16.000000000 +0200
9 +++ freepbx-module-ivr/install.php      2007-02-18 12:11:38.000000000 +0200
10 @@ -1,9 +1,37 @@
11  <?php
12 -sql('CREATE TABLE IF NOT EXISTS ivr ( ivr_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, displayname VARCHAR(50), deptname VARCHAR(50), enable_directory VARCHAR(8), enable_directdial VARCHAR(8), timeout INT, announcement VARCHAR(255), dircontext VARCHAR ( 50 ) DEFAULT "default" )');
13 -sql('CREATE TABLE IF NOT EXISTS ivr_dests ( ivr_id INT NOT NULL, selection VARCHAR(10), dest VARCHAR(50))');
14 -
15  global $db;
16  
17 +// install the tables
18 +$autoincrement = (($amp_conf["AMPDBENGINE"] == "sqlite") || ($amp_conf["AMPDBENGINE"] == "sqlite3")) ? "AUTOINCREMENT":"AUTO_INCREMENT";
19 +
20 +$sql = "CREATE TABLE IF NOT EXISTS ivr (
21 +       ivr_id INTEGER NOT NULL $autoincrement PRIMARY KEY,
22 +       displayname VARCHAR(50),
23 +       deptname VARCHAR(50),
24 +       enable_directory VARCHAR(8),
25 +       enable_directdial VARCHAR(8),
26 +       timeout INTEGER,
27 +       announcement VARCHAR(255),
28 +       dircontext VARCHAR ( 50 ) DEFAULT \"default\"
29 +);";
30 +$check = $db->query($sql);
31 +if (DB::IsError($check)) {
32 +        die( "Can not create `ivr` table: " . $check->getMessage() .  "\n");
33 +}
34 +
35 +$sql = "CREATE TABLE IF NOT EXISTS ivr_dests (
36 +       ivr_id INTEGER NOT NULL,
37 +       selection VARCHAR(10),
38 +       dest VARCHAR(50),
39 +       ivr_ret TINYINT(1) NOT NULL DEFAULT 0
40 +);";
41 +$check = $db->query($sql);
42 +if (DB::IsError($check)) {
43 +        die( "Can not create `ivrdests` table: " . $check->getMessage() .  "\n");
44 +}
45 +
46 +$ivr_modcurrentvers = modules_getversion('ivr');
47 +
48  // Now, we need to check for upgrades.
49  // V1.0, old IVR. You shouldn't see this, but check for it anyway, and assume that it's 2.0
50  // V2.0, Original Release
51 @@ -11,8 +39,6 @@
52  // v2.2, announcement changed to support filenames instead of ID's from recordings table
53  //
54  
55 -$ivr_modcurrentvers = modules_getversion('ivr');
56 -
57  // Add the col
58  $sql = "SELECT dircontext FROM ivr";
59  $check = $db->getRow($sql, DB_FETCHMODE_ASSOC);
60 diff -urNad freepbx-module-ivr~/install.sql freepbx-module-ivr/install.sql
61 --- freepbx-module-ivr~/install.sql     2007-02-10 00:34:16.000000000 +0200
62 +++ freepbx-module-ivr/install.sql      1970-01-01 02:00:00.000000000 +0200
63 @@ -1,2 +0,0 @@
64 -CREATE TABLE IF NOT EXISTS ivr ( ivr_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, displayname VARCHAR(50), deptname VARCHAR(50), enable_directory VARCHAR(8), enable_directdial VARCHAR(8), timeout INT, announcement VARCHAR(255), dircontext VARCHAR ( 50 ) DEFAULT "default" );
65 -CREATE TABLE IF NOT EXISTS ivr_dests ( ivr_id INT NOT NULL, selection VARCHAR(10), dest VARCHAR(50), ivr_ret TINYINT(1) NOT NULL DEFAULT 0);
Donate



Support
Download
Develop
Forums
News
Documentation
Paid Support
About

Paid Ads