-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.sql
1431 lines (1369 loc) · 56.6 KB
/
init.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
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
DO $$
BEGIN
IF NOT EXISTS (SELECT FROM pg_catalog.pg_roles WHERE rolname = 'root') THEN
CREATE ROLE root WITH LOGIN PASSWORD 'root';
END IF;
END
$$;
-- drop
DO $$
DECLARE
r RECORD;
BEGIN
-- Drop all tables
FOR r IN (SELECT tablename FROM pg_tables WHERE schemaname = 'public') LOOP
EXECUTE 'DROP TABLE IF EXISTS ' || quote_ident(r.tablename) || ' CASCADE';
END LOOP;
-- Drop all types
FOR r IN (
SELECT typname
FROM pg_type
WHERE typnamespace = 'public'::regnamespace
AND typtype = 'e' -- Only drop ENUM types
) LOOP
EXECUTE 'DROP TYPE IF EXISTS ' || quote_ident(r.typname) || ' CASCADE';
END LOOP;
END $$;
-- extension
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
-- type
DO $$
BEGIN
-- role_name type
IF NOT EXISTS (
SELECT 1
FROM pg_type
WHERE typname = 'role_name'
) THEN
CREATE TYPE role_name AS ENUM (
'ROLE_TSL',
'ROLE_DIRECTOR',
'ROLE_ADMIN',
'ROLE_ENVIRONMENT_OFFICER',
'ROLE_MANAGEMENT',
'ROLE_THIRD_PARTY'
);
END IF;
-- company_unit_type type
IF NOT EXISTS (
SELECT 1
FROM pg_type
WHERE typname = 'company_unit_type'
) THEN
CREATE TYPE company_unit_type AS ENUM ('MAIN', 'SUB');
END IF;
-- user_status type
IF NOT EXISTS (
SELECT 1
FROM pg_type
WHERE typname = 'user_status'
) THEN
CREATE TYPE user_status AS ENUM (
'ACTIVE',
'INACTIVE',
'SUSPENDED',
'PENDING',
'IN_REVIEW',
'APPROVED',
'APPROVED_WO_INDUSTRY',
'APPROVED_WO_INDUSTRY_AND_MAIN_UNIT',
'REJECTED',
'CORRECTION'
);
END IF;
-- unit_type type
IF NOT EXISTS (
SELECT 1
FROM pg_type
WHERE typname = 'unit_type'
) THEN
CREATE TYPE unit_type AS ENUM ('length', 'weight', 'count', 'other');
END IF;
-- resource_type type
IF NOT EXISTS (
SELECT 1
FROM pg_type
WHERE typname = 'resource_type'
) THEN
CREATE TYPE resource_type AS ENUM (
'raw_material',
'product',
'byproduct',
'fuel',
'waste',
'other'
);
END IF;
-- transaction_type type
IF NOT EXISTS (
SELECT 1
FROM pg_type
WHERE typname = 'transaction_type'
) THEN
CREATE TYPE transaction_type AS ENUM ('IN', 'OUT');
END IF;
-- designation_type type
IF NOT EXISTS (
SELECT 1
FROM pg_type
WHERE typname = 'designation_type'
) THEN
CREATE TYPE designation_type AS ENUM (
'TSL',
'Administrator',
'Manager',
'Director',
'Environment Officer',
'Third Party'
);
END IF;
-- email_status type
IF NOT EXISTS (
SELECT 1
FROM pg_type
WHERE typname = 'email_status'
) THEN
CREATE TYPE email_status AS ENUM (
'VERIFIED',
'NOT_VERIFIED',
'PENDING'
);
END IF;
-- form_status type
IF NOT EXISTS (
SELECT 1
FROM pg_type
WHERE typname = 'form_status'
) THEN
CREATE TYPE form_status AS ENUM (
'incomplete',
'complete',
'pending',
'under review',
'approved',
'rejected'
);
END IF;
END $$;
-- tables
CREATE TABLE role (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
name role_name UNIQUE
);
CREATE TABLE email(
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
email_id VARCHAR(255) NOT NULL,
email_status email_status DEFAULT 'NOT_VERIFIED'
);
CREATE TABLE address (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
street VARCHAR(255),
line2 VARCHAR(255),
line3 VARCHAR(255),
city VARCHAR(255),
state VARCHAR(255),
district VARCHAR(255),
country VARCHAR(255),
pincode VARCHAR(20),
village VARCHAR(255),
taluka VARCHAR(255),
plot_number VARCHAR(255),
ro VARCHAR(255),
sro VARCHAR(255)
);
CREATE TABLE contact_person (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
name VARCHAR(255) NOT NULL,
designation VARCHAR(255),
phone VARCHAR(255),
email_id UUID,
FOREIGN KEY (email_id) REFERENCES email(id)
);
CREATE TABLE industry_category (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
name VARCHAR(255) UNIQUE
);
CREATE TABLE industry_scale (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
name VARCHAR(255) UNIQUE
);
CREATE TABLE industry_type (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
name VARCHAR(1024) UNIQUE
);
CREATE TABLE industry_link (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
industry_scale_id UUID,
industry_type_id UUID,
industry_category_id UUID,
FOREIGN KEY (industry_category_id) REFERENCES industry_category(id) ON DELETE SET NULL,
FOREIGN KEY (industry_scale_id) REFERENCES industry_scale(id) ON DELETE SET NULL,
FOREIGN KEY (industry_type_id) REFERENCES industry_type(id) ON DELETE SET NULL
);
CREATE TABLE company_profile (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
contact_person_id UUID,
name VARCHAR(255),
fax VARCHAR(255),
phone_number VARCHAR(255),
website VARCHAR(255),
established_at DATE,
registration_number VARCHAR(50),
address_id UUID,
email_id UUID,
FOREIGN KEY (email_id) REFERENCES email(id),
FOREIGN KEY (address_id) REFERENCES address(id) ON DELETE SET NULL,
FOREIGN KEY (contact_person_id) REFERENCES contact_person(id)
);
CREATE TABLE company_unit (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
company_profile_id UUID,
address_id UUID,
industry_link_id UUID,
name VARCHAR(50),
type company_unit_type,
unit_fax VARCHAR(255),
unit_phone_number VARCHAR(255),
work_day INT,
working_hour INT,
email_id UUID,
FOREIGN KEY (email_id) REFERENCES email(id),
FOREIGN KEY (address_id) REFERENCES address(id) ON DELETE SET NULL,
FOREIGN KEY (company_profile_id) REFERENCES company_profile(id) ON DELETE CASCADE,
FOREIGN KEY (industry_link_id) REFERENCES industry_link(id) ON DELETE SET NULL
);
CREATE TABLE users (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
email_id UUID,
phone VARCHAR(20),
username VARCHAR(50) NOT NULL UNIQUE,
password VARCHAR(100) NOT NULL,
enabled BOOLEAN,
designation designation_type,
company_unit_id UUID,
failed_login_count INT CHECK (failed_login_count >= 0),
last_login_date TIMESTAMPTZ,
locked BOOLEAN,
status user_status DEFAULT 'INACTIVE',
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW(),
FOREIGN KEY (email_id) REFERENCES email(id),
FOREIGN KEY (company_unit_id) REFERENCES company_unit(id) ON DELETE SET NULL
);
CREATE TABLE user_role (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
user_id UUID NOT NULL,
role_id UUID NOT NULL,
UNIQUE (user_id, role_id),
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
FOREIGN KEY (role_id) REFERENCES role(id) ON DELETE CASCADE
);
CREATE TABLE employee (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
company_id UUID,
user_id UUID NOT NULL,
contact_person_id UUID,
name VARCHAR(500),
gender VARCHAR(20),
date_of_birth DATE,
form_status form_status DEFAULT 'incomplete',
FOREIGN KEY (company_id) REFERENCES company_profile(id),
FOREIGN KEY (user_id) REFERENCES users(id),
FOREIGN KEY (contact_person_id) REFERENCES contact_person(id)
);
CREATE TABLE email_template (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
name VARCHAR(100) NOT NULL UNIQUE,
subject VARCHAR(255) NOT NULL,
body TEXT NOT NULL
);
CREATE TABLE email_outbox (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
recipient_email VARCHAR(255) NOT NULL,
subject VARCHAR(255) NOT NULL,
body TEXT NOT NULL,
sent_date TIMESTAMPTZ DEFAULT NOW(),
status VARCHAR(16),
email_id UUID,
FOREIGN KEY (email_id) REFERENCES email(id)
);
CREATE TABLE unit (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
name VARCHAR(50),
symbol VARCHAR(10),
unit_type unit_type,
conversion_factor NUMERIC(10, 5)
);
CREATE TABLE resource (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
unit_id UUID,
name VARCHAR(255) NOT NULL,
quantity NUMERIC(10, 2),
resource_type resource_type,
FOREIGN KEY (unit_id) REFERENCES unit(id)
);
CREATE TABLE resource_transaction (
id UUID NOT NULL,
company_unit_id UUID NOT NULL,
resource_id UUID NOT NULL,
transaction_type transaction_type NOT NULL,
quantity NUMERIC(10, 2) NOT NULL,
timestamp TIMESTAMPTZ NOT NULL,
FOREIGN KEY (resource_id) REFERENCES resource(id) ON DELETE CASCADE
) PARTITION BY LIST (company_unit_id);
CREATE TABLE notification_type (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
name VARCHAR(50) UNIQUE,
description TEXT,
type VARCHAR(50),
priority INT
);
CREATE TABLE notification (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
user_id UUID NOT NULL,
from_user UUID,
message TEXT,
notification_type UUID NOT NULL,
pinned BOOLEAN DEFAULT FALSE,
is_read BOOLEAN DEFAULT FALSE,
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
trigger_date DATE NOT NULL,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
FOREIGN KEY (from_user) REFERENCES users(id) ON DELETE SET NULL,
FOREIGN KEY (notification_type) REFERENCES notification_type(id) ON DELETE CASCADE
);
-- partitions
CREATE OR REPLACE FUNCTION create_resource_transaction_partition()
RETURNS TRIGGER AS $$
DECLARE
partition_name TEXT;
partition_exists BOOLEAN;
BEGIN
partition_name := 'resource_transaction_' || NEW.id::text;
-- Check if the partition already exists
SELECT EXISTS (
SELECT FROM information_schema.tables
WHERE table_schema = current_schema()
AND table_name = partition_name
) INTO partition_exists;
-- If the partition doesn't exist, create it
IF NOT partition_exists THEN
EXECUTE format('CREATE TABLE %I PARTITION OF resource_transaction FOR VALUES IN (%L)', partition_name, NEW.id);
EXECUTE format('ALTER TABLE %I ADD PRIMARY KEY (id)', partition_name);
EXECUTE format('CREATE INDEX ON %I (timestamp)', partition_name);
END IF;
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
-- triggers
CREATE TRIGGER create_resource_transaction_partition_trigger
AFTER INSERT ON company_unit
FOR EACH ROW
EXECUTE FUNCTION create_resource_transaction_partition();
-- data
INSERT INTO email (id, email_id) VALUES
(uuid_generate_v4(), '[email protected]'),
(uuid_generate_v4(), '[email protected]'),
(uuid_generate_v4(), '[email protected]'),
(uuid_generate_v4(), '[email protected]'),
(uuid_generate_v4(), '[email protected]'),
(uuid_generate_v4(), '[email protected]'),
(uuid_generate_v4(), '[email protected]'),
(uuid_generate_v4(), '[email protected]'),
(uuid_generate_v4(), '[email protected]'),
(uuid_generate_v4(), '[email protected]'),
(uuid_generate_v4(), '[email protected]'),
(uuid_generate_v4(), '[email protected]'),
(uuid_generate_v4(), '[email protected]'),
(uuid_generate_v4(), '[email protected]'),
(uuid_generate_v4(), '[email protected]'),
(uuid_generate_v4(), '[email protected]'),
(uuid_generate_v4(), '[email protected]'),
(uuid_generate_v4(), '[email protected]'),
(uuid_generate_v4(), '[email protected]'),
(uuid_generate_v4(), '[email protected]'),
(uuid_generate_v4(), '[email protected]'),
(uuid_generate_v4(), '[email protected]'),
(uuid_generate_v4(), '[email protected]'),
(uuid_generate_v4(), '[email protected]'),
(uuid_generate_v4(), '[email protected]'),
(uuid_generate_v4(), '[email protected]'),
(uuid_generate_v4(), '[email protected]'),
(uuid_generate_v4(), '[email protected]'),
(uuid_generate_v4(), '[email protected]');
INSERT INTO contact_person (id, name, designation, phone, email_id)
VALUES
(uuid_generate_v4(), 'Ajay Ojha', 'MD', '9876543212', (SELECT id FROM email WHERE email_id = '[email protected]')),
(uuid_generate_v4(), 'Prasad Pawar', 'CEO', '9876543212', (SELECT id FROM email WHERE email_id = '[email protected]')),
(uuid_generate_v4(), 'Ritesh Gujar', 'IT', '9876543212', (SELECT id FROM email WHERE email_id = '[email protected]'));
INSERT INTO role (name) VALUES
('ROLE_TSL'),
('ROLE_DIRECTOR'),
('ROLE_ADMIN'),
('ROLE_ENVIRONMENT_OFFICER'),
('ROLE_MANAGEMENT'),
('ROLE_THIRD_PARTY');
INSERT INTO industry_category (name) VALUES
('GREEN'),
('ORANGE'),
('RED'),
('WHITE');
INSERT INTO industry_scale (name) VALUES
('LSI'),
('MSI'),
('SSI');
INSERT INTO industry_type (name) VALUES
('Local Body'),
('G95 CBG plants based on crop residue (paddy straw /wheat straw /corn sweet sorghum /napier grass, etc.)'),
('O93 Without any surface treatment activity such as washing, metal surface finishing operations, pickling, plating, electroplating, phosphating & without heat treatment'),
('G64 Railway Stations(Waste Water Generation < 10 KLD)'),
('G65 Gaushalas'),
('G24 Heat treatment with any of the new technology like ultrasound probe, induction hardening, ionization beam, gas carburizing etc.'),
('G40 Rolling mill (gas fired) and cold rolling mill'),
('G01 Aluminium utensils from aluminium circles.'),
('G2 Ayurvedic and homeopathic medicines (without boiler)'),
('G3 Bakery/confectionery/sweets products (with production capacity <1tpd (with gas or electrical oven))'),
('G4 Bi-axially oriented PP film along with metalizing operations'),
('G5 Biomass briquettes (sun drying) without using toxic hazardous wastes'),
('G6 Blending of melamine resins & different powder, additives by physical mixing'),
('G7 Brass and bell metal utensils manufacturing from circles(dry mechanical operation without re-rolling facility)'),
('G8 Candy'),
('G9 Cardboard or corrugated box and paper products (excluding paper or pulp manufacturing and without using boilers)'),
('G10 Carpentry & wooden furniture manufacturing (excluding saw mill) with the help of electrical (motorized) machines such as electrical wood planner, steel saw cutting circular blade, etc.'),
('G11 Cement products (without using asbestos / boiler / steam curing) like pipe, pillar, jafri, well ring, block/tiles etc.(should be done in closed covered shed to control fugitive emissions)'),
('G12 Ceramic colour manufacturing by mixing & blending only (not using boiler and wastewater recycling process)'),
('G13 Chilling plant, cold storage and ice making'),
('G14 Coke briquetting (sun drying)'),
('G15 Cotton spinning and weaving (small scale)'),
('G16 Dal Mills'),
('G17 Decoration of ceramic cups and plates by electric furnace'),
('G18 Digital printing on PVC clothes'),
('G19 Facility of handling, storage and transportation of food grains in bulk'),
('G20 Flour mills (dry process)'),
('G21 Glass, ceramic, earthen potteries, tile and tile manufacturing using electrical kiln or not involving fossil fuel kiln'),
('G22 Glue from starch (physical mixing) with gas / electrically operated oven /boiler'),
('G23 Gold and silver smithy (purification with acid smelting operation and sulphuric acid polishing operation) (using less or equal to 1 litre of sulphuric acid/ nitric acid per month)'),
('G25 Insulation and other coated papers (excluding paper or pipe manufacturing)'),
('G26 Leather footwear and leather products (excluding tanning and hide processing except cottage scale)'),
('G27 Lubricating oil, greases or petroleum based products (only blending at normal temperature)'),
('G28 Manufacturing of pasted veneers using gas fired boiler or thermic fluid heater and by sun drying'),
('G29 Oil mill Ghani and extraction (no hydrogenation / refining)'),
('G30 Packing materials manufacturing from non asbestos fibre, vegetable fibre yarn'),
('G31 Phenyl/toilet cleaner formulation and bottling'),
('G32 Polythene and plastic processed products manufacturing (virgin plastic)'),
('G33 Poultry, Hatchery and Piggery'),
('G34 Power looms (without dye and bleaching)'),
('G35 Puffed rice (muri) (using gas or electrical heating system)'),
('G36 Pulverization of bamboo and scrap wood'),
('G38 Reprocessing of waste cotton'),
('G39 Rice mill (Rice hullers only)'),
('G41 Rubber goods industry (with gas operated baby)'),
('G42 Saw mills'),
('G43 Soap manufacturing (hand made without steam boiling/ boiler)'),
('G44 Spice grinding (upto-20 HP motor)'),
('G45 Spice grinding (>20 hp motor)'),
('G46 Steel furniture without spray painting'),
('G47 Steeping and processing of grains'),
('G48 Tyres and tube retreating (without boilers)'),
('G49 Chilling plant and ice making without using ammonia'),
('G50 CO2 recovery'),
('G51 Distilled water (without boiler) with electricity as source of heat'),
('G52 Hotels (up to 20 rooms and without boilers)'),
('G53 Manufacturing of optical lenses (using electrical furnace)'),
('G54 Mineralized water'),
('G55 Tamarind powder manufacturing'),
('G56 Cutting, sizing and polishing of marble stone'),
('G57 Emery powder (fine dust of sand) manufacturing'),
('G58 Flyash export, transport & disposal facilities'),
('G59 Mineral stack yard / Railway sidings'),
('G60 Oil and gas transportation pipeline'),
('G61 Seasoning of wood in steam heated chamber'),
('G62 Synthetic detergent formulation'),
('G63 Tea processing (with boiler)'),
('O1 Dismantling of rolling stocks (wagons/ coaches)'),
('O2 Bakery and confectionery units with production capacity > 1 TPD. (With ovens / furnaces)'),
('O3 Chanachur and ladoo from puffed and beaten rice (muri and shira) using husk fired oven'),
('O4 Coated electrode manufacturing'),
('O5 Compact disc computer floppy and cassette manufacturing / Reel manufacturing'),
('O6 Flakes from rejected PET bottle'),
('O7 Food and food processing including fruits and vegetable processing'),
('O8 Jute processing without dyeing'),
('O9 Manufacturing of silica gel'),
('O10 Manufacturing of tooth powder, toothpaste, talcum powder and other cosmetic items'),
('O11 Printing or etching of glass sheet using hydrofluoric acid'),
('O12 Silk screen printing, sari printing by wooden blocks'),
('O13 Synthetic detergents and soaps (excluding formulation)'),
('O15 Cotton spinning and weaving (medium and large scale)'),
('O16 Almirah, Grill Manufacturing (Dry Mechanical Process)'),
('O17 Aluminium & copper extraction from scrap using oil fired furnace (dry process only)'),
('O18 Automobile servicing, repairing and painting (excluding only fuel dispensing)'),
('O19 Ayurvedic and homeopathic medicine'),
('O20 Brickfields (excluding fly ash brick manufacturing using lime process)'),
('O21 Building and construction project more than 20,000 sq. m built up area'),
('O22 Ceramics and Refractories'),
('O23 Coal washeries'),
('O24 Dairy and dairy products (small scale)'),
('O25 DG set of capacity >1MVA but < 5MVA'),
('O26 Dry coal processing, mineral processing, industries involving ore sintering, pelletizing, grinding & pulverization'),
('O27 Fermentation industry including manufacture of yeast, beer, distillation of alcohol (Extra Neutral Alcohol)'),
('O28 Ferrous and Non-ferrous metal extraction involving different furnaces through melting, refining, re-processing, casting and alloy-making'),
('O29 Fertilizer (granulation / formulation / blending only)'),
('O30 Fish feed, poultry feed and cattle feed'),
('O31 Fish processing and packing (excluding chilling of fishes)'),
('O32 Forging of ferrous and non-ferrous metals (using oil and gas fired furnaces)'),
('O33 Formulation/pelletization of camphor tablets, naphthalene balls from camphor/ naphthalene powders.'),
('O34 Glass ceramics, earthen potteries and tile manufacturing using oil and gas fired kilns, coating on glasses using cerium fluorides and magnesium fluoride etc.'),
('O35 Gravure printing, digital printing on flex, vinyl'),
('O37 Hot mix plants'),
('O38 Hotels (< 3 star) or hotels having > 20 rooms and less than 100 rooms'),
('O39 Ice cream'),
('O42 Industry or processes involving foundry operations'),
('O43 Lime manufacturing (using lime kiln)'),
('O44 Liquid floor cleaner, black phenyl, liquid soap, glycerol mono-stearate manufacturing'),
('O45 Manufacturing of glass'),
('O46 Manufacturing of iodized salt from crude/raw salt'),
('O47 Manufacturing of mirror from sheet glass'),
('O48 Manufacturing of mosquito repellent coil'),
('O49 Manufacturing of Starch/Sago'),
('O50 Mechanized laundry using oil fired boiler'),
('O51 Modular wooden furniture from particle board, MDF < swan timber etc, Ceiling tiles/partition board from saw dust, wood chips etc., and other agricultural waste using synthetic adhesive resin, wooden box making (With boiler)'),
('O52 New highway construction project'),
('O53 Non-alcoholic beverages(soft drink) & bottling of alcohol/non alcoholic products'),
('O54 Paint blending and mixing (Ball mill)'),
('O55 Paints and varnishes (mixing and blending)'),
('O56 Ply-board manufacturing (including Veneer and laminate) with oil fired boiler/ thermic fluid heater(without resin plant)'),
('O57 Potable alcohol (IMFL) by blending, bottling of alcohol products'),
('O58 Printing ink manufacturing'),
('O60 Reprocessing of waste plastic including PVC'),
('O62 Spray painting, paint baking, paint shipping'),
('O63 Steel and steel products using various furnaces like blast furnace/open hearth furnace/induction furnace/arc furnace/submerged arc furnace/basic oxygen furnace/hot rolling reheated furnace'),
('O64 Stone crushers'),
('O65 Surgical and medical products including prophylactics and latex'),
('O66 Teflon based products'),
('O68 Tobacco products including cigarettes and tobacco/opium processes'),
('O69 Transformer repairing/manufacturing (dry process only)'),
('O70 Tyres and tubes vulcanization/hot retreating'),
('O71 Vegetable oil manufacturing including solvent extraction and refinery/hydrogenated oils'),
('O72 Wire drawing and wire netting'),
('O73 Dry cell battery (excluding manufacturing of electrodes) and assembling & charging of acid lead battery on micro scale'),
('O74 Pharmaceutical formulation and for R&D purpose (For sustained release/extended release of drugs only and not for commercial purpose)'),
('O75 Synthetic resins'),
('O76 Synthetic rubber excluding molding'),
('O77 Cashew nut processing'),
('O78 Coffee seed processing'),
('O79 Parboiled Rice Mills'),
('O80 Foam manufacturing'),
('O83 Producer gas plant using conventional up drift coal gasification (linked to rolling mills glass and ceramic industry refectories for dedicated fuel supply)'),
('O14 Thermometer manufacturing'),
('O36 Heat treatment using oil fired furnace (without cyaniding)'),
('O40 Industries engaged in recycling/reprocessing/recovery/reuse of Hazardous Waste under schedule iv of HW(M, H & TBM) rules, 2008 - Items namely -B148Paint and ink sludge/residues'),
('O41 Industries engaged in recycling/reprocessing/recovery/reuse of Hazardous Waste under schedule iv of HW(M, H & TBM) rules, 2008 - Items namely - Brass Dross, Copper Dross, Copper Oxide Mill Scale, Copper Reverts, Cake & Residues, Waste Copper and copper alloys in dispersible form, Slags from copper processing for further processing or refining, Insulated Copper Wire, Scrap/copper with PVC sheathing including ISRI-code material namely Druid, Jelly filled Copper cables, Zinc Dross-Hot dip Galvanizers SLAB, Zinc Dross-Bottom Dross, Zinc ash/Skimming arising from galvanizing and die casting operations, Zinc ash/Skimming/other zinc bearing wastes arising from smelting and refining, Zinc ash and residues including zinc alloy residues in dispersible form'),
('O61 Rolling mill (oil or coal fired) and cold rolling mill'),
('O67 Thermocol manufacturing (with boiler)'),
('O81 Industries engaged in recycling/reprocessing/recovery/reuse of Hazardous Waste under schedule iv of HW(M, H & TBM) rules, 2008 - Items namely -Used Oil – As per specifications prescribed from time to time'),
('O82 Industries engaged in recycling/reprocessing/recovery/reuse of Hazardous Waste under schedule iv of HW(M, H & TBM) rules, 2008 - Items namely -Waste Oil ---As per specifications prescribed from time to time'),
('Restaurant activity having overall waste water generated upto 10 KLD'),
('O84 Railway Stations (Waste Water Generation >= 10 KLD, but <100 KLD)'),
('O85 Scrapping Centers (for End of Life of Vehicles and other scraps such as plant and machineries, structural material, railway coaches and wagons etc.)'),
('a. Collection, De-Pollution, Dismantling Centers and Shredding Centers'),
('b. Collection, De-Pollution, Dismantling Centers and Shredding Centers'),
('c. Shredding Centers (can include white goods*/other scraps also)'),
('O86 Compressed/Refined Bio-Gas Production from Bio-degradables Wastes'),
('O87 Dairy farms'),
('O90A Ready mix cement concrete'),
('Assaying & hallmarking centers'),
('O89 CBG plants based on Municipal Solid Waste (MSW)'),
('O90 CBG plants based on process waste (industrial/process liquid effluent & solid waste like press mud, organic sludge, molasses, etc.)'),
('R61 Dead Animal incineration plant (Carcass disposal plant)'),
('R89 Sterilization process by using Gamma Rays using COBALT-60'),
('R61 Railway Stations (Waste Water Generation >= 100 KLD)'),
('Pyrolysis oil from plastic waste'),
('Municipal corporation STP'),
('Restaurant activity having overall waste water generated more than 10 KLD'),
('R3 Industries engaged in recycling/reprocessing/recovery/reuse of Hazardous Waste under schedule iv of HW(M, H & TBM) rules, 2008 - Items namely - Spent cleared metal catalyst containing copper, Spent cleared metal catalyst containing zinc'),
('R10 Industries engaged in recycling/reprocessing/recovery/reuse of Hazardous Waste under schedule iv of HW(M, H & TBM) rules, 2008 - Items namely - Spent catalyst containing nickel, cadmium, Zinc, copper, arsenic, vanadium and cobalt'),
('R15 Industries engaged in recycling/reprocessing/recovery/reuse of Hazardous Waste under schedule iv of HW(M, H & TBM) rules, 2008 - Items namely - Dismantlers Recycling Plants -- Components of waste electrical and electronic assemblies comprising accumulators and other batteries included on list A, mercury-switches, activated glass cullets from cathode-ray tubes and other activated glass and PCB-capacitors, or any other component contaminated with Schedule 2 constituents (e.g. cadmium, mercury, lead, polychlorinated biphenyl) to an extent that they exhibit hazard characteristics indicated in part C of this Schedule'),
('R18 Pulp & Paper (waste paper based without bleaching process to manufacture Kraft paper)'),
('R32 Industries engaged in recycling/reprocessing/recovery/reuse of Hazardous Waste under schedule iv of HW(M, H & TBM) rules, 2008'),
('R33 Industries engaged in recycling/reprocessing/recovery/reuse of Hazardous Waste under schedule iv of HW(M, H & TBM) rules, 2008 - Items namely - Integrated Recycling Plants -- Components of waste electrical and electronic assemblies comprising accumulators and other batteries included on list A, mercury-switches, activated glass cullets from cathode-ray tubes and other activated glass and PCB-capacitors, or any other component contaminated with Schedule 2 constituents (e.g. cadmium, mercury, lead, polychlorinated biphenyl) to an extent that they exhibit hazard characteristics indicated in part C of this Schedule'),
('R54 Pulp & Paper (waste paper based units with bleaching process to manufacture writing & printing paper)'),
('R59 Pulp & Paper (Large-Agro + wood), Small Pulp & Paper (agro based-wheat straw/rice husk)'),
('R1 Isolated storage of hazardous chemicals (as per schedule of manufacturing, storage of hazardous chemicals rules, 1989 as amended)'),
('R2 Automobile Manufacturing (integrated facilities)'),
('R4 Manufacturing of lubricating oils, grease and petroleum based products'),
('R5 DG Set of capacity > 5 MVA'),
('R6 Industrial carbon including electrodes and graphite blocks, activated carbon, carbon black'),
('R7 Lead acid battery manufacturing (excluding assembling and charging of lead-acid battery in micro scale)'),
('R8 Phosphate rock processing plant'),
('R9 Power generation plant [except Wind and Solar renewable power plants of all capacities and Mini Hydel power plant of capacity <25MW]'),
('R11 Processes involving chlorinated hydrocarbons'),
('R12 Sugar (excluding Khandsari)'),
('R13 Fibre glass production and processing (excluding moulding)'),
('R14 Fire crackers manufacturing and bulk storage facilities'),
('R16 Milk processes and dairy products (integrated project)'),
('R17 Phosphorous and its compounds'),
('R19 Coke making, liquefaction, coal tar distillation or fuel gas making'),
('R20 Manufacturing of explosives, detonators, fuses including management and handling activities'),
('R21 Manufacturing of paints varnishes, pigments and intermediate (excluding blending/mixing)'),
('R22 Organic Chemicals manufacturing'),
('R23 Airports and Commercial Air Strips'),
('R24 Asbestos and asbestos based industries'),
('R25 Basic chemicals and electro chemicals and its derivatives including manufacturing of acid'),
('R26 Cement'),
('R27 Chlorates, per-chlorates & peroxides'),
('R28 Chlorine, fluorine, bromine, iodine and their compounds'),
('R29 Dyes and Dye-Intermediates'),
('R31 Hotels having overall waste-water generation @ 100 KLD and more'),
('R34 Manufacturing of glue and gelatin'),
('R35 Mining and ore beneficiation'),
('R36 Nuclear power plant'),
('R37 Pesticides (technical) (excluding formulation)'),
('R38 Photographic film and its chemicals'),
('R39 Railway locomotive workshop/Integrated road transport workshop/Authorized service centers'),
('R40 Yarn/Textile processing involving any effluent/emission generating processes including bleaching, dyeing, printing and colouring'),
('R41 Chlor Alkali'),
('R42 Ship Breaking Industries'),
('R43 Oil and gas extraction including CBM (offshore & on-shore extraction through drilling wells)'),
('R44 Industry or process involving metal surface treatment or process such as pickling/electroplating/paint stripping/heat treatment using cyanide bath/phosphating or finishing and anodizing/enamellings/galvanizing'),
('R45 Tanneries'),
('R46 Ports and harbour, jetties and dredging operations'),
('R47 Synthetic fibers including rayon, tyre cord, polyester filament yarn'),
('R48 Thermal Power Plants'),
('R49 Slaughter house (as per notification S.O.270(E) dated 26.03.2001) and meat processing industries, bone mill, processing of animal horn, hoofs and other body parts'),
('R50 Aluminium Smelter'),
('R51 Copper Smelter'),
('R52 Fertilizer (basic) (excluding formulation)'),
('R53 Iron & Steel (involving processing from ore/integrated steel plants) and or Sponge Iron units'),
('R55 Zinc Smelter'),
('R56 Oil Refinery (mineral Oil or Petro Refineries)'),
('R57 Petrochemicals Manufacturing (including processing of Emulsions of oil and water)'),
('R58 Pharmaceuticals'),
('R60 Distillery (molasses/grain/yeast based)'),
('W38 CBG plants (irrespective of the type of feed) producing Fermented Organic Manure (FOM) & Liquid Fermented Organic Manure (LFOM) as by-products'),
('Other');
INSERT INTO industry_link (id, industry_category_id, industry_scale_id, industry_type_id)
VALUES
(
uuid_generate_v4(),
(SELECT id FROM industry_category WHERE name = 'GREEN'),
(SELECT id FROM industry_scale WHERE name = 'LSI'),
(SELECT id FROM industry_type WHERE name = 'O90A Ready mix cement concrete')
),
(
uuid_generate_v4(),
(SELECT id FROM industry_category WHERE name = 'ORANGE'),
(SELECT id FROM industry_scale WHERE name = 'MSI'),
(SELECT id FROM industry_type WHERE name = 'R55 Zinc Smelter')
);
INSERT INTO company_profile (
id,
contact_person_id,
name,
email_id,
fax,
phone_number,
website,
established_at,
registration_number,
address_id
)
VALUES
(
uuid_generate_v4(),
(SELECT id FROM contact_person WHERE name = 'Ajay Ojha'),
'Techknowgreen Ltd.',
(SELECT id FROM email WHERE email_id = '[email protected]'),
'123-456-7890',
'1234567890',
'www.techknowgreen.com',
'2018-08-20',
'444444444444',
NULL
),
(
uuid_generate_v4(),
(SELECT id FROM contact_person WHERE name = 'Ritesh Gujar'),
'Techknowblue Ltd.',
(SELECT id FROM email WHERE email_id = '[email protected]'),
'098-765-4321',
'0987654321',
'www.techknowblue.com',
'2018-08-27',
'444444444444',
NULL
);
INSERT INTO address (
id,
street,
line2,
line3,
city,
state,
district,
country,
pincode,
village,
taluka,
plot_number,
ro,
sro
)
VALUES
(
uuid_generate_v4(),
'101, 102',
'Ekta Society',
'Hem Opal',
'Wakdewadi',
'Maharashtra',
'Pune',
'India',
'411005',
'Village A',
'Taluka A',
'Plot No. 26',
'RO1',
'SRO1'
),
(
uuid_generate_v4(),
'New Lane',
'Orchid Society',
'Gandhi Road',
'New Mumbai',
'Maharashtra',
'Mumbai',
'India',
'400001',
'Village A',
'Taluka A',
'Plot No. 26',
'RO1',
'SRO1'
),
(
uuid_generate_v4(),
'456 Elm St',
'Block B',
'Karol Bagh',
'New Delhi',
'Delhi',
'New Delhi',
'India',
'110005',
'Village B',
'Taluka B',
'Plot 2',
'RO2',
'SRO2'
),
(
uuid_generate_v4(),
'789 Oak St',
'Suite 100',
'Connaught Place',
'New Delhi',
'Delhi',
'New Delhi',
'India',
'110002',
'Village C',
'Taluka C',
'Plot 3',
'RO3',
'SRO3'
),
(
uuid_generate_v4(),
'123 Maple St',
'Apt 200',
'Saket',
'Chennai',
'Tamil Nadu',
'Chennai',
'India',
'600001',
'Village D',
'Taluka D',
'Plot 4',
'RO4',
'SRO4'
);
INSERT INTO company_unit (
id,
company_profile_id,
address_id,
industry_link_id,
name,
type,
email_id,
unit_fax,
unit_phone_number,
work_day,
working_hour
)
VALUES
(
uuid_generate_v4(),
(SELECT id FROM company_profile WHERE name = 'Techknowgreen Ltd.'),
(SELECT id FROM address WHERE district = 'Pune'),
(SELECT id FROM industry_link WHERE industry_category_id = (SELECT id FROM industry_category WHERE name = 'GREEN') AND industry_scale_id = (SELECT id FROM industry_scale WHERE name = 'LSI') AND industry_type_id = (SELECT id FROM industry_type WHERE name = 'O90A Ready mix cement concrete')),
'TSL Main Unit',
'MAIN',
(SELECT id FROM email WHERE email_id = '[email protected]'),
'123-456-7890',
'123-456-7890',
5,
8
),
(
uuid_generate_v4(),
(SELECT id FROM company_profile WHERE name = 'Techknowgreen Ltd.'),
(SELECT id FROM address WHERE district = 'Mumbai'),
(SELECT id FROM industry_link WHERE industry_category_id = (SELECT id FROM industry_category WHERE name = 'ORANGE') AND industry_scale_id = (SELECT id FROM industry_scale WHERE name = 'MSI') AND industry_type_id = (SELECT id FROM industry_type WHERE name = 'R55 Zinc Smelter')),
'TSL Sub Unit 1',
'SUB',
(SELECT id FROM email WHERE email_id = '[email protected]'),
'098-765-4321',
'098-765-4321',
6,
7
),
(
uuid_generate_v4(),
(SELECT id FROM company_profile WHERE name = 'Techknowgreen Ltd.'),
(SELECT id FROM address WHERE street = '456 Elm St'),
(SELECT id FROM industry_link WHERE industry_category_id = (SELECT id FROM industry_category WHERE name = 'GREEN') AND industry_scale_id = (SELECT id FROM industry_scale WHERE name = 'LSI') AND industry_type_id = (SELECT id FROM industry_type WHERE name = 'O90A Ready mix cement concrete')),
'TSL Sub Unit 2',
'SUB',
(SELECT id FROM email WHERE email_id = '[email protected]'),
'111-222-3333',
'111-222-3333',
5,
8
),
(
uuid_generate_v4(),
(SELECT id FROM company_profile WHERE name = 'Techknowblue Ltd.'),
(SELECT id FROM address WHERE street = '789 Oak St'),
(SELECT id FROM industry_link WHERE industry_category_id = (SELECT id FROM industry_category WHERE name = 'ORANGE') AND industry_scale_id = (SELECT id FROM industry_scale WHERE name = 'MSI') AND industry_type_id = (SELECT id FROM industry_type WHERE name = 'R55 Zinc Smelter')),
'TBL Main Unit',
'MAIN',
(SELECT id FROM email WHERE email_id = '[email protected]'),
'444-555-6666',
'444-555-6666',
6,
7
),
(
uuid_generate_v4(),
(SELECT id FROM company_profile WHERE name = 'Techknowblue Ltd.'),
(SELECT id FROM address WHERE street = '123 Maple St'),
(SELECT id FROM industry_link WHERE industry_category_id = (SELECT id FROM industry_category WHERE name = 'GREEN') AND industry_scale_id = (SELECT id FROM industry_scale WHERE name = 'LSI') AND industry_type_id = (SELECT id FROM industry_type WHERE name = 'O90A Ready mix cement concrete')),
'TBL Sub Unit 1',
'SUB',
(SELECT id FROM email WHERE email_id = '[email protected]'),
'777-888-9999',
'777-888-9999',
5,
8
);
INSERT INTO users (
id,
email_id,
phone,
username,
password,
enabled,
designation,
company_unit_id,
failed_login_count,
last_login_date,
locked,
status
)
VALUES
(
uuid_generate_v4(),
(SELECT id FROM email WHERE email_id = '[email protected]'),
'1234567890',
'tsl',
'$2a$12$vYPpThZEkVYeGZl8TpVTmORZLzIDnJwYYhgeF6oz/cbo3WoQbxgBa',
TRUE,
'TSL',
NULL,
0,
NOW(),
FALSE,
'ACTIVE'
),
(
uuid_generate_v4(),
(SELECT id FROM email WHERE email_id = '[email protected]'),
'1234567890',
'director1',
'$2a$12$A0A1tWXqhTmzEjQ6J90Qr.aXoDo0.3wsO8zNdBA8lF5DTCozTbcJy',
TRUE,
'Director',
(SELECT id FROM company_unit WHERE name = 'TSL Main Unit' AND type = 'MAIN'),
0,
NOW(),
FALSE,
'ACTIVE'
),
(
uuid_generate_v4(),
(SELECT id FROM email WHERE email_id = '[email protected]'),
'1234567890',
'admin1',
'$2a$12$k/ubhOxFf8v5JwJAd63TieQOxmrlK0..437AhLOk.TV05PKb59i8G',
TRUE,
'Administrator',
(SELECT id FROM company_unit WHERE name = 'TSL Main Unit' AND type = 'MAIN'),
0,
NOW(),
FALSE,
'ACTIVE'
),
(
uuid_generate_v4(),
(SELECT id FROM email WHERE email_id = '[email protected]'),
'1234567890',
'1env1',
'$2a$12$Yw2kVbSGVSqDuWVuUDrqh.874D4T6cv/Mttn/r068Z60V5/3AO4mW',
TRUE,
'Environment Officer',
(SELECT id FROM company_unit WHERE name = 'TSL Main Unit' AND type = 'MAIN'),
0,
NOW(),
FALSE,
'ACTIVE'
),
(
uuid_generate_v4(),
(SELECT id FROM email WHERE email_id = '[email protected]'),
'1234567890',
'1man1',
'$2a$12$75tj6mIUUTcqX4IP470h6.HFX6P988JjpTB3/oe.rtkyOluMKB9Hq',
TRUE,