<commit_before>spring:
  profiles: information_schema

tables: |
  select * from (
    select t.table_schema   as "schema"
         , t.table_name     as "table"
         , t.table_schema || '/tables/' || t.table_name || '/main.sql' as "@file_name"
      from information_schema.tables t
     where lower(t.table_schema) like '$schema'
       and lower(t.table_name) like '$table'
     order by t.table_name)

table.create: |
  create table "$schema"."$table.name" (<%srv.get('column').each {%>
    !{it.name.padRight(20)}!{it.properties.data_type.toLowerCase()}!{it.properties.length}<%if (it != srv.get('column').last()){%>,<%}}%>
  );

table.drop: |
  drop table $schema.$table;

table.info: |
  r=srv.get('column')
  table(border:'1'){
    caption('"HR"."USERS"')
    tr{th('COLUMN')th('TYPE')th('SIZE')}
    r.each{
      nm=it
      tr{td(nm.name)td(nm.properties.data_type)td(nm.properties.length)}
    }
  }


table.columns: |
  select * from (
    select c.table_schema   as "schema"
         , c.table_name     as "table"
         , c.column_name    as "column"
         , c.type_name      as "@data_type"
         , case when c.type_name like 'VARCHAR%' then '('|| c.character_maximum_length ||')' end as "@length"
         , c.nullable       as "@nullable"
         , c.column_default as "@column_default"
    from information_schema.columns c
   where lower(c.table_schema) like '$schema'
     and lower(c.table_name) like '$table'
     and lower(c.column_name) like '$column'
   order by c.ordinal_position asc)


table.column.create: |
  alter table $table add column $column.name;

table.column.drop: |
  alter table $table drop $column.name;


table.pk: |
  select * from (
    select c.table_schema as "schema"
         , c.table_name as "table"
         , c.constraint_name as "pk"
         , c.table_schema || '/tables/' || c.table_name || '/pk.sql' as "@file_name"
         , c.sql as "@sql"
      from information_schema.constraints c
     where constraint_type  = 'PRIMARY KEY'
       and lower(table_schema) like '$schema'
       and lower(table_name) like '$table'
       and lower(constraint_name) like '$pk')

table.pk.create: |
  !{pk.properties.sql};

table.pk.drop: |
  alter table $table drop pk $pk.name;


table.indexes: |
  select * from (
    select c.table_schema as "schema"
         , c.table_name as "table"
         , c.index_name as "index"
         , c.table_schema || '/tables/' || c.table_name || '/indexes/' || c.index_name || '.sql' as "@file_name"
         , c.sql as "@sql"
      from information_schema.indexes c
     where index_type_name <> 'PRIMARY KEY'
       and lower(table_schema) like '$schema'
       and lower(table_name) like '$table'
       and lower(index_name) like '$index')

table.index.create: |
  !{index.properties.sql};

table.index.drop: |
  drop index $index.name;


table.checks: |
  select * from (
    select c.table_schema as "schema"
         , c.table_name as "table"
         , c.constraint_name as "check"
         , c.table_schema || '/tables/' || c.table_name || '/indexes/' || c.constraint_name || '.sql' as "@file_name"
         , c.sql as "@sql"
      from information_schema.constraints c
     where constraint_type = 'CHECK'
       and lower(table_schema) like '$schema'
       and lower(table_name) like '$table'
       and lower(constraint_name) like '$check')

table.check.create: |
  !{check.properties.sql};

table.check.drop: |
  drop check $check.name;


views: |
  select * from (
    select t.table_schema   as "schema"
         , t.table_name     as "view"
         , t.view_definition as "@sql"
         , t.table_schema || '/views/' || t.table_name || '.sql' as "@file_name"
      from information_schema.views t
     where lower(t.table_schema) like '$schema'
       and lower(t.table_name) like '$table'
     order by t.table_name)

view.create: |
  !{view.properties.sql};

view.drop: |
  drop view $view.name;


mviews: |
  select * from (
    select t.table_schema   as "schema"
         , t.table_name     as "view"
         , t.view_definition as "@sql"
         , t.table_schema || '/views/' || t.table_name || '.sql' as "@file_name"
      from information_schema.views t
     where lower(t.table_schema) like '$schema'
       and lower(t.table_name) like '$table'
       and lower(t.table_name) like '%_materialized'
     order by t.table_name)

mview.create: |
  create table "$schema"."$mview.name" (<%srv.get('column').each {%>
    !{it.name.padRight(20)}!{it.properties.data_type.toLowerCase()}!{it.properties.length}<%if (it != srv.get('column').last()){%>,<%}}%>
  );

mview.drop: |
  drop table $mview.name;


---
spring:
  profiles: postgres

table: |
  select t.table_schema     as "schema"
       , t.table_name       as "table"
    from information_schema.tables t
   where t.table_type='BASE TABLE'
     and lower(t.table_schema) like '$schema'
     and lower(t.table_name) like '$table'

table.create: |
  create table "$schema"."$table" (<%srv.get('column').each {%>
    !{it.name.padRight(20)}!{it.properties.data_type.toLowerCase()}!{it.properties.length}<%if (it != srv.get('column').last()){%>,<%}}%>
  );

table.drop: |
  drop table $schema.$table;

table.column: |
  select c.table_schema     as "schema"
       , c.table_name       as "table"
       , c.column_name      as "column"
       , c.udt_name         as "@data_type"
       , case when c.udt_name like 'varchar%' then '('|| c.character_maximum_length ||')' end as "@length"
       , c.is_nullable      as "@is_nullable"
       , c.column_default   as "@column_default"
    from information_schema.columns c
        ,information_schema.tables t
   where t.table_schema = c.table_schema
     and t.table_name = c.table_name
     and t.table_type='BASE TABLE'
     and lower(c.table_schema) like '$schema'
     and lower(c.table_name) like '$table'
     and lower(c.column_name) like '$column'
   order by c.ordinal_position asc<commit_msg>set table name for html output<commit_after>spring:
  profiles: information_schema

tables: |
  select * from (
    select t.table_schema   as "schema"
         , t.table_name     as "table"
         , t.table_schema || '/tables/' || t.table_name || '/main.sql' as "@file_name"
      from information_schema.tables t
     where lower(t.table_schema) like '$schema'
       and lower(t.table_name) like '$table'
     order by t.table_name)

table.create: |
  create table "$schema"."$table.name" (<%srv.get('column').each {%>
    !{it.name.padRight(20)}!{it.properties.data_type.toLowerCase()}!{it.properties.length}<%if (it != srv.get('column').last()){%>,<%}}%>
  );

table.drop: |
  drop table $schema.$table;

table.info: |
  r=srv.get('column')
  table(border:'1'){
    caption('"'+schema+'"."'+table.name+'"')
    tr{th('COLUMN')th('TYPE')th('SIZE')}
    r.each{
      nm=it
      tr{td(nm.name)td(nm.properties.data_type)td(nm.properties.length)}
    }
  }


table.columns: |
  select * from (
    select c.table_schema   as "schema"
         , c.table_name     as "table"
         , c.column_name    as "column"
         , c.type_name      as "@data_type"
         , case when c.type_name like 'VARCHAR%' then '('|| c.character_maximum_length ||')' end as "@length"
         , c.nullable       as "@nullable"
         , c.column_default as "@column_default"
    from information_schema.columns c
   where lower(c.table_schema) like '$schema'
     and lower(c.table_name) like '$table'
     and lower(c.column_name) like '$column'
   order by c.ordinal_position asc)


table.column.create: |
  alter table $table add column $column.name;

table.column.drop: |
  alter table $table drop $column.name;


table.pk: |
  select * from (
    select c.table_schema as "schema"
         , c.table_name as "table"
         , c.constraint_name as "pk"
         , c.table_schema || '/tables/' || c.table_name || '/pk.sql' as "@file_name"
         , c.sql as "@sql"
      from information_schema.constraints c
     where constraint_type  = 'PRIMARY KEY'
       and lower(table_schema) like '$schema'
       and lower(table_name) like '$table'
       and lower(constraint_name) like '$pk')

table.pk.create: |
  !{pk.properties.sql};

table.pk.drop: |
  alter table $table drop pk $pk.name;


table.indexes: |
  select * from (
    select c.table_schema as "schema"
         , c.table_name as "table"
         , c.index_name as "index"
         , c.table_schema || '/tables/' || c.table_name || '/indexes/' || c.index_name || '.sql' as "@file_name"
         , c.sql as "@sql"
      from information_schema.indexes c
     where index_type_name <> 'PRIMARY KEY'
       and lower(table_schema) like '$schema'
       and lower(table_name) like '$table'
       and lower(index_name) like '$index')

table.index.create: |
  !{index.properties.sql};

table.index.drop: |
  drop index $index.name;


table.checks: |
  select * from (
    select c.table_schema as "schema"
         , c.table_name as "table"
         , c.constraint_name as "check"
         , c.table_schema || '/tables/' || c.table_name || '/indexes/' || c.constraint_name || '.sql' as "@file_name"
         , c.sql as "@sql"
      from information_schema.constraints c
     where constraint_type = 'CHECK'
       and lower(table_schema) like '$schema'
       and lower(table_name) like '$table'
       and lower(constraint_name) like '$check')

table.check.create: |
  !{check.properties.sql};

table.check.drop: |
  drop check $check.name;


views: |
  select * from (
    select t.table_schema   as "schema"
         , t.table_name     as "view"
         , t.view_definition as "@sql"
         , t.table_schema || '/views/' || t.table_name || '.sql' as "@file_name"
      from information_schema.views t
     where lower(t.table_schema) like '$schema'
       and lower(t.table_name) like '$table'
     order by t.table_name)

view.create: |
  !{view.properties.sql};

view.drop: |
  drop view $view.name;


mviews: |
  select * from (
    select t.table_schema   as "schema"
         , t.table_name     as "view"
         , t.view_definition as "@sql"
         , t.table_schema || '/views/' || t.table_name || '.sql' as "@file_name"
      from information_schema.views t
     where lower(t.table_schema) like '$schema'
       and lower(t.table_name) like '$table'
       and lower(t.table_name) like '%_materialized'
     order by t.table_name)

mview.create: |
  create table "$schema"."$mview.name" (<%srv.get('column').each {%>
    !{it.name.padRight(20)}!{it.properties.data_type.toLowerCase()}!{it.properties.length}<%if (it != srv.get('column').last()){%>,<%}}%>
  );

mview.drop: |
  drop table $mview.name;


---
spring:
  profiles: postgres

table: |
  select t.table_schema     as "schema"
       , t.table_name       as "table"
    from information_schema.tables t
   where t.table_type='BASE TABLE'
     and lower(t.table_schema) like '$schema'
     and lower(t.table_name) like '$table'

table.create: |
  create table "$schema"."$table" (<%srv.get('column').each {%>
    !{it.name.padRight(20)}!{it.properties.data_type.toLowerCase()}!{it.properties.length}<%if (it != srv.get('column').last()){%>,<%}}%>
  );

table.drop: |
  drop table $schema.$table;

table.column: |
  select c.table_schema     as "schema"
       , c.table_name       as "table"
       , c.column_name      as "column"
       , c.udt_name         as "@data_type"
       , case when c.udt_name like 'varchar%' then '('|| c.character_maximum_length ||')' end as "@length"
       , c.is_nullable      as "@is_nullable"
       , c.column_default   as "@column_default"
    from information_schema.columns c
        ,information_schema.tables t
   where t.table_schema = c.table_schema
     and t.table_name = c.table_name
     and t.table_type='BASE TABLE'
     and lower(c.table_schema) like '$schema'
     and lower(c.table_name) like '$table'
     and lower(c.column_name) like '$column'
   order by c.ordinal_position asc
{'fraction_non_alphanumeric': 0.15289464826657692, 'fraction_numerical': 0.0011780545270952542, 'mean_word_length': 2.8129611806223935, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5648862', 'n_tokens_mistral': 4099, 'n_tokens_neox': 4063, 'n_words': 902}