-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdb_script_Postgres.sql
798 lines (731 loc) · 19.7 KB
/
db_script_Postgres.sql
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
CREATE SCHEMA public AUTHORIZATION postgres;
CREATE TYPE _BK2_mt_sentencia (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = BK2_mt_sentencia,
DELIMITER = ',');
CREATE TYPE _BK_mt_sentencia (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = BK_mt_sentencia,
DELIMITER = ',');
CREATE TYPE _BK_mt_sentencia_region (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = BK_mt_sentencia_region,
DELIMITER = ',');
CREATE TYPE _BK_tt_antecedente (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = BK_tt_antecedente,
DELIMITER = ',');
CREATE TYPE _BK_tt_encabezado (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = BK_tt_encabezado,
DELIMITER = ',');
CREATE TYPE _BK_tt_radicado (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = BK_tt_radicado,
DELIMITER = ',');
CREATE TYPE _mt_dane_censo_2018 (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = mt_dane_censo_2018,
DELIMITER = ',');
CREATE TYPE _mt_dane_estrato (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = mt_dane_estrato,
DELIMITER = ',');
CREATE TYPE _mt_dane_geo (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = mt_dane_geo,
DELIMITER = ',');
CREATE TYPE _mt_sentencia (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = mt_sentencia,
DELIMITER = ',');
CREATE TYPE _mt_sentencia_rest (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = mt_sentencia_rest,
DELIMITER = ',');
CREATE TYPE _temp_new_resuelve (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = temp_new_resuelve,
DELIMITER = ',');
CREATE TYPE _temp_test_resuelve (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = temp_test_resuelve,
DELIMITER = ',');
CREATE TYPE _tt_area (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = tt_area,
DELIMITER = ',');
CREATE TYPE _tt_carga_pdf (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = tt_carga_pdf,
DELIMITER = ',');
CREATE TYPE _tt_cedula_catastral (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = tt_cedula_catastral,
DELIMITER = ',');
CREATE TYPE _tt_encabezado (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = tt_encabezado,
DELIMITER = ',');
CREATE TYPE _tt_grupo_familiar (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = tt_grupo_familiar,
DELIMITER = ',');
CREATE TYPE _tt_indice_sentencia (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = tt_indice_sentencia,
DELIMITER = ',');
CREATE TYPE _tt_juez_magristrado (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = tt_juez_magristrado,
DELIMITER = ',');
CREATE TYPE _tt_localizacion (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = tt_localizacion,
DELIMITER = ',');
CREATE TYPE _tt_log_transaccion (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = tt_log_transaccion,
DELIMITER = ',');
CREATE TYPE _tt_matricula_inmobiliaria (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = tt_matricula_inmobiliaria,
DELIMITER = ',');
CREATE TYPE _tt_model_predict (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = tt_model_predict,
DELIMITER = ',');
CREATE TYPE _tt_opositor (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = tt_opositor,
DELIMITER = ',');
CREATE TYPE _tt_ordena_beneficios (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = tt_ordena_beneficios,
DELIMITER = ',');
CREATE TYPE _tt_ordena_entidades (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = tt_ordena_entidades,
DELIMITER = ',');
CREATE TYPE _tt_radicado (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = tt_radicado,
DELIMITER = ',');
CREATE TYPE _tt_radicado_rest (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = tt_radicado_rest,
DELIMITER = ',');
CREATE TYPE _tt_resuelve (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = tt_resuelve,
DELIMITER = ',');
CREATE TYPE _tt_resuelve_text (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = tt_resuelve_text,
DELIMITER = ',');
CREATE TYPE _tt_sentencia_geo (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = tt_sentencia_geo,
DELIMITER = ',');
CREATE TYPE _tt_solicitante (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = tt_solicitante,
DELIMITER = ',');
CREATE TYPE _vw_certificado_radicacion_finalizado (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = vw_certificado_radicacion_finalizado,
DELIMITER = ',');
CREATE TYPE _vw_pendiente_modelo (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = vw_pendiente_modelo,
DELIMITER = ',');
CREATE TYPE _vw_rol_beneficiario (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = vw_rol_beneficiario,
DELIMITER = ',');
CREATE TYPE _vw_sentencia (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = vw_sentencia,
DELIMITER = ',');
CREATE TYPE _vw_tipo_sentencia_grupo (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = vw_tipo_sentencia_grupo,
DELIMITER = ',');
CREATE TYPE _vw_tipo_zona (
INPUT = array_in,
OUTPUT = array_out,
RECEIVE = array_recv,
SEND = array_send,
ANALYZE = array_typanalyze,
ALIGNMENT = 8,
STORAGE = any,
CATEGORY = A,
ELEMENT = vw_tipo_zona,
DELIMITER = ',');
CREATE TABLE mt_dane_censo_2018 (
codane text NULL,
departamento text NULL,
municipio text NULL,
total int4 NULL,
hombre int4 NULL,
mujer int4 NULL,
sin_estrato int4 NULL,
estrato_1 int4 NULL,
estrato_2 int4 NULL,
estrato_3 int4 NULL,
estrato_4 int4 NULL,
estrato_5 int4 NULL,
estrato_6 int4 NULL,
no_sabe int4 NULL,
not_applicable int4 NULL,
hombre_sin_estrato int4 NULL,
hombre_estrato_1 int4 NULL,
hombre_estrato_2 int4 NULL,
hombre_estrato_3 int4 NULL,
hombre_estrato_4 int4 NULL,
hombre_estrato_5 int4 NULL,
hombre_estrato_6 int4 NULL,
hombre_no_sabe int4 NULL,
hombre_not_applicable int4 NULL,
mujer_sin_estrato int4 NULL,
mujer_estrato_1 int4 NULL,
mujer_estrato_2 int4 NULL,
mujer_estrato_3 int4 NULL,
mujer_estrato_4 int4 NULL,
mujer_estrato_5 int4 NULL,
mujer_estrato_6 int4 NULL,
mujer_no_sabe int4 NULL,
mujer_not_applicable int4 NULL,
fecha_creacion_registro timestamp NULL DEFAULT now()
);
CREATE TABLE mt_dane_estrato (
codane text NULL,
departamento text NULL,
municipio text NULL,
total int4 NULL,
sin_estrato int4 NULL,
estrato_1 int4 NULL,
estrato_2 int4 NULL,
estrato_3 int4 NULL,
estrato_4 int4 NULL,
estrato_5 int4 NULL,
estrato_6 int4 NULL,
no_sabe int4 NULL,
fecha_creacion_registro timestamp NULL DEFAULT now()
);
CREATE TABLE mt_dane_geo (
codigo_dep text NULL,
codigo_mun text NULL,
codigo_cp text NULL,
nombre_dep text NULL,
nombre_mun text NULL,
nombre_cp text NULL,
tipo_cp text NULL,
longitud float8 NULL,
latitud float8 NULL,
nombre_distrito text NULL,
municipio_anm text NULL,
nombre_area_metrop text NULL,
fecha_creacion_registro timestamp NULL DEFAULT now()
);
CREATE TABLE mt_sentencia (
certificado text NULL,
clase text NULL,
descargar text NULL,
ciudad text NULL,
estado text NULL DEFAULT 'Nuevo'::text,
paginas text NULL,
tipo_archivo text NULL,
fecha_creacion_registro timestamp NULL DEFAULT now()
);
CREATE TABLE tt_area (
"key" text NULL,
area text NULL,
conteo int8 NULL,
fecha_creacion_registro timestamp NULL DEFAULT now()
);
CREATE TABLE tt_carga_pdf (
"key" text NULL,
probability float8 NULL,
error_ratio float8 NULL,
low_quality text NULL,
fecha_creacion_registro timestamp NULL DEFAULT now()
);
CREATE TABLE tt_cedula_catastral (
cedula_catastral text NULL,
principal text NULL,
"key" text NULL,
fecha_creacion_registro timestamp NULL DEFAULT now()
);
CREATE TABLE tt_encabezado (
"key" text NULL,
clase text NULL,
descripcion text NULL,
fecha text NULL,
fecha_formato text NULL,
fecha_creacion_registro timestamp NULL DEFAULT now()
);
CREATE TABLE tt_grupo_familiar (
grupo text NULL,
n_persona text NULL,
"name" text NULL,
"key" text NULL,
cedula text NULL,
fecha_creacion_registro timestamp NULL DEFAULT now()
);
CREATE TABLE tt_indice_sentencia (
"key" text NULL,
numeral text NULL,
texto text NULL,
linea int4 NULL,
tipo text NULL,
fecha_creacion_registro timestamp NULL DEFAULT now()
);
CREATE TABLE tt_juez_magristrado (
"key" text NULL,
"index" int8 NULL,
parte text NULL,
original float8 NULL,
nombre_jm text NULL,
ponente int4 NULL,
lead_sentence text NULL,
fecha_creacion_registro timestamp NULL DEFAULT now()
);
CREATE TABLE tt_localizacion (
certificado text NULL,
departamento text NULL,
codigo_departamento text NULL,
municipio text NULL,
codigo_municipio text NULL,
corregimiento text NULL,
codigo_corregimiento text NULL,
vereda text NULL,
codigo_vereda text NULL,
fecha_creacion_registro timestamp NULL DEFAULT now()
);
CREATE TABLE tt_log_transaccion (
operacion text NULL,
comentario text NULL DEFAULT ''::text,
fecha timestamp NULL DEFAULT now()
);
CREATE TABLE tt_matricula_inmobiliaria (
matricula_inmobiliaria text NULL,
principal text NULL,
"key" text NULL,
fecha_creacion_registro timestamp NULL DEFAULT now()
);
CREATE TABLE tt_model_predict (
accuracy float8 NULL,
"precision" float8 NULL,
sensitivity float8 NULL,
specificity float8 NULL,
f1_score float8 NULL,
model text NULL,
auc float8 NULL,
fecha_creacion_registro timestamp NULL DEFAULT now()
);
CREATE TABLE tt_opositor (
"key" text NULL,
"index" int8 NULL,
nombre_opositor text NULL,
cedula text NULL,
fecha_creacion_registro timestamp NULL DEFAULT now()
);
CREATE TABLE tt_ordena_beneficios (
"key" text NULL,
contador int8 NULL,
beneficio text NULL,
fecha_creacion_registro timestamp NULL DEFAULT now()
);
CREATE TABLE tt_ordena_entidades (
"key" text NULL,
contador int8 NULL,
entidad text NULL,
fecha_creacion_registro timestamp NULL DEFAULT now()
);
CREATE TABLE tt_radicado (
certificado text NULL,
radicacion text NULL,
nombre_predio text NULL,
municipio_vereda text NULL,
fecha_providencia text NULL,
id_despacho text NULL,
despacho_judicial text NULL,
anio text NULL,
cantidad_sentencias text NULL,
adiciona_complementa text NULL,
fecha_ultima_sentencia text NULL,
fecha_creacion_registro timestamp NULL DEFAULT now()
);
CREATE TABLE tt_resuelve (
certificado text NULL,
resuelve text NULL,
radicado text NULL,
orden_vivienda text NULL,
proyectos_productivos_beneficiarios_restitucion text NULL,
compensacion_victimas text NULL,
compensacion_terceros text NULL,
segundos_ocupantes text NULL,
alivio_predial text NULL,
alivio_servicios_publicos text NULL,
alivio_pasivos_financieros text NULL,
pagos_costas_gastos_judiciales text NULL,
administracion_proyectos_productivos_agroindustriales text NULL,
otras_ordenes text NULL,
ordenes_direccion_social text NULL,
ordenes_catastrales text NULL,
usa_modelo text NULL DEFAULT 'NO'::text,
fecha_creacion_registro timestamp NULL DEFAULT now()
);
CREATE TABLE tt_resuelve_text (
"key" text NULL,
contador int8 NULL,
texto text NULL,
orderna text NULL,
beneficios text NULL,
articulos text NULL,
fecha_creacion_registro timestamp NULL DEFAULT now()
);
CREATE TABLE tt_sentencia_geo (
"key" text NULL,
latitud text NULL,
longitud text NULL,
fecha_creacion_registro timestamp NULL DEFAULT now()
);
CREATE TABLE tt_solicitante (
nombre text NULL,
principal int8 NULL,
"key" text NULL,
cedula text NULL,
fecha_creacion_registro timestamp NULL DEFAULT now()
);
CREATE OR REPLACE VIEW public.vw_certificado_radicacion_finalizado
AS SELECT ms.certificado AS "Certificado",
tr.radicacion AS "Radicación"
FROM mt_sentencia ms
JOIN tt_radicado tr ON tr.certificado = ms.certificado;
CREATE OR REPLACE VIEW public.vw_pendiente_modelo
AS SELECT tt_resuelve.certificado,
tt_resuelve.resuelve,
tt_resuelve.radicado,
tt_resuelve.orden_vivienda,
tt_resuelve.proyectos_productivos_beneficiarios_restitucion,
tt_resuelve.compensacion_victimas,
tt_resuelve.compensacion_terceros,
tt_resuelve.segundos_ocupantes,
tt_resuelve.alivio_predial,
tt_resuelve.alivio_servicios_publicos,
tt_resuelve.alivio_pasivos_financieros,
tt_resuelve.pagos_costas_gastos_judiciales,
tt_resuelve.administracion_proyectos_productivos_agroindustriales,
tt_resuelve.otras_ordenes,
tt_resuelve.ordenes_direccion_social,
tt_resuelve.ordenes_catastrales,
tt_resuelve.usa_modelo
FROM tt_resuelve
WHERE (tt_resuelve.orden_vivienda IS NULL OR tt_resuelve.orden_vivienda = ''::text) AND (tt_resuelve.proyectos_productivos_beneficiarios_restitucion IS NULL OR tt_resuelve.proyectos_productivos_beneficiarios_restitucion = ''::text) AND (tt_resuelve.compensacion_victimas IS NULL OR tt_resuelve.compensacion_victimas = ''::text) AND (tt_resuelve.compensacion_terceros IS NULL OR tt_resuelve.compensacion_terceros = ''::text) AND (tt_resuelve.segundos_ocupantes IS NULL OR tt_resuelve.segundos_ocupantes = ''::text) AND (tt_resuelve.alivio_predial IS NULL OR tt_resuelve.alivio_predial = ''::text) AND (tt_resuelve.alivio_servicios_publicos IS NULL OR tt_resuelve.alivio_servicios_publicos = ''::text) AND (tt_resuelve.alivio_pasivos_financieros IS NULL OR tt_resuelve.alivio_pasivos_financieros = ''::text) AND (tt_resuelve.pagos_costas_gastos_judiciales IS NULL OR tt_resuelve.pagos_costas_gastos_judiciales = ''::text) AND (tt_resuelve.administracion_proyectos_productivos_agroindustriales IS NULL OR tt_resuelve.administracion_proyectos_productivos_agroindustriales = ''::text) AND (tt_resuelve.otras_ordenes IS NULL OR tt_resuelve.otras_ordenes = ''::text) AND (tt_resuelve.ordenes_direccion_social IS NULL OR tt_resuelve.ordenes_direccion_social = ''::text) AND (tt_resuelve.ordenes_catastrales IS NULL OR tt_resuelve.ordenes_catastrales = ''::text);
CREATE OR REPLACE VIEW public.vw_rol_beneficiario
AS SELECT tgf.grupo,
tgf.n_persona,
tgf.name,
tgf.key,
tgf.cedula,
CASE
WHEN tgf.n_persona = '1'::text THEN 'Titular'::text
ELSE 'Beneficiario'::text
END AS rol
FROM tt_grupo_familiar tgf;
CREATE OR REPLACE VIEW public.vw_tipo_sentencia_grupo
AS SELECT tmp_grp.key,
CASE
WHEN tmp_grp.c_grupos = '1'::text THEN 'Individual'::text
ELSE 'Colectiva'::text
END AS tipo
FROM ( SELECT tgf.key,
max(tgf.grupo) AS c_grupos
FROM tt_grupo_familiar tgf
GROUP BY tgf.key) tmp_grp;
CREATE OR REPLACE VIEW public.vw_tipo_zona
AS SELECT tl.certificado,
tl.codigo_vereda,
tmp_dane_cp.tipo_cp,
CASE
WHEN tl.codigo_vereda IS NOT NULL AND tl.codigo_vereda <> 'Not Found'::text THEN 'Rural'::text
WHEN tmp_dane_cp.tipo_cp IS NOT NULL THEN
CASE
WHEN tmp_dane_cp.tipo_cp = 'CENTRO POBLADO'::text THEN 'Rural'::text
WHEN tmp_dane_cp.tipo_cp = 'CABECERA MUNICIPAL'::text THEN 'Urbano'::text
ELSE 'Rural (Probable)'::text
END
ELSE 'Rural (Probable)'::text
END AS tipo
FROM tt_localizacion tl
LEFT JOIN ( SELECT DISTINCT mt_dane_geo.codigo_cp,
mt_dane_geo.tipo_cp
FROM mt_dane_geo) tmp_dane_cp ON tmp_dane_cp.codigo_cp = tl.codigo_corregimiento;