]> git.nbdom.net Git - nb.git/commitdiff
sql.drop
authorNicolas Boisselier <nicolas.boisselier@semantico.com>
Tue, 2 Aug 2016 15:56:36 +0000 (16:56 +0100)
committerNicolas Boisselier <nicolas.boisselier@semantico.com>
Tue, 2 Aug 2016 15:56:36 +0000 (16:56 +0100)
etc/dbs/ui.php
lib/php/db.php
lib/php/db/types/pgsql.php

index ce6a69e6faae9f61a382cce05a69996eefb28a17..26b0426b1f698489a1bd8d433f9a57276173253a 100644 (file)
@@ -165,6 +165,13 @@ $CONF['_ui'] = array(
 $CONF['ui'] = array(
   '_import' => array('_ui'),
 );
+$CONF['ui-pgsql'] = array(
+  'host' => 'ui.semantico.net',
+  'type' => 'pgsql',
+  'name' => 'ui',
+  'pdo' => '',
+  '_import' => array('_ui','_semadm'),
+);
 $CONF['ui-mysql'] = array(
   'host' => 'ui.semantico.net',
   'type' => 'mysql',
index 003ce194e086c2552190ad1e6d9d69b4f7b8d8bd..0269eea2ef1e8f4b10b5216d5d182dd731ad4604 100644 (file)
@@ -662,7 +662,14 @@ return;
 
       $sql = rtrim($t->create(),';');
       $sql = str_replace(';CREATE',";\nCREATE",$sql);
-      $t->sql_create = 'DROP '.strtoupper($t->type).' IF EXISTS '.$t->sql_name().';'.NB_EOL
+
+      if ($drop = $this->type('sql.drop')) {
+        $drop = str_replace('<NAME>',$t->name,$drop);
+        $drop = str_replace('<TYPE>',strtoupper($t->type),$drop);
+      } else {
+        $drop = 'DROP '.strtoupper($t->type).' IF EXISTS '.$t->sql_name();
+      }
+      $t->sql_create = $drop.';'.NB_EOL
         .$sql.';'.NB_EOL
       ;
 
index 44dbeaf6b3bd1235cfcbe1b73bf238942791f34c..1a6e31e3f86177f8964382444ffc3bb45296f57b 100644 (file)
@@ -23,18 +23,27 @@ ORDER BY 1",
 */
 'databases' => 'SELECT datname as name,pg_catalog.pg_get_userbyid(datdba) as owner,pg_catalog.pg_encoding_to_char(encoding) as encoding, datcollate as "collate",datctype as "Ctype" FROM pg_catalog.pg_database',
 
+'sql.drop' => 'DROP <TYPE> IF EXISTS "<NAME>" CASCADE',
 'tables' => "SELECT table_name as name,LOWER(CASE table_type WHEN 'BASE TABLE' THEN 'TABLE' ELSE table_type END) as type,table_type FROM information_schema.tables WHERE table_type in('BASE TABLE','VIEW') AND table_schema NOT IN ('pg_catalog', 'information_schema')",
 
-'create' => function(&$field) {
+# NB 02.08.16 'create' => function(&$field) {
+# NB 02.08.16   $r = array(
+# NB 02.08.16     '/datetime/i' => 'timestamp',
+# NB 02.08.16     '/float/i' => 'numeric',
+# NB 02.08.16     '/ COLLATE NOCASE/i' => '',
+# NB 02.08.16   );
+# NB 02.08.16   $field->type = preg_replace(array_keys($r),array_values($r),$field->type);
+# NB 02.08.16 },
+
+'sql.replace' => function($sql) {
+  $sql = preg_replace('/ESCAPE \'.*?\'/','',$sql);
   $r = array(
     '/datetime/i' => 'timestamp',
+    '/float\(/i' => 'numeric(',
+    '/\w*int\(/i' => 'numeric(',
     '/ COLLATE NOCASE/i' => '',
   );
-  $field->type = preg_replace(array_keys($r),array_values($r),$field->type);
-},
-
-'sql.replace' => function($sql) {
-  $sql = preg_replace('/ESCAPE \'.*?\'/','',$sql);
+  $sql= preg_replace(array_keys($r),array_values($r),$sql);
   return $sql;
 },