 
 
 
+
+
+
+
+
 (defn make-users-table []
   (let [coils-admin-tables      (korma.core/exec-raw
                                  [" select * from pg_tables where schemaname='public' and tablename='coils_users'" []]



(defn make-log-table-delete-trigger-function []
    (let [coils-trigger-fn-exists-result      (korma.core/exec-raw
                                                  ["select exists(select * from pg_proc where proname = 'trigger_function_afterDelete');" []]
                                                  :results)

          coils-trigger-fn-exists   (= "t"  coils-trigger-fn-exists-result)

          sql-to-create-trigger-fn "
CREATE OR REPLACE FUNCTION trigger_function_afterDelete()
      RETURNS trigger AS
$BODY$
      BEGIN
           INSERT INTO coils_realtime_log
                 (record_timestamp,  record_table_name,  record_id,  record_operation,  record_status)
           VALUES
                 ( now(),   TG_TABLE_NAME ,  OLD.id,  'DELETE',  'WAITING');
           RETURN NULL;
      END;
$BODY$
LANGUAGE plpgsql;
"
          ]

        ;(println "Coils trigger function exists: " coils-trigger-fn-exists)
        (if (not coils-trigger-fn-exists )
            (korma.core/exec-raw   [sql-to-create-trigger-fn []]   [])
            nil
            )
        )
    )








  (make-todo-table)
  (make-users-table)
  (make-admin-table )
  (make-log-table   )











(defn !get-show-debug []
  {:value *show-code*})










