Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix initial DB seeding script #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,24 @@ To create an order to be picked by Extract, send this script to the ```Geoshop's

```sql

--- Create an Order (A rectangle)
INSERT INTO "order" (title, description, processing_fee_currency, processing_fee, total_without_vat_currency, total_without_vat, part_vat_currency, part_vat, total_with_vat_currency, total_with_vat, geom, invoice_reference, date_ordered, date_downloaded, date_processed, client_id, invoice_contact_id, order_type_id, extract_result, download_guid, email_deliver, order_status) VALUES ('New demo order', '', 'CHF', NULL, 'CHF', NULL, 'CHF', NULL, 'CHF', NULL, '0103000020080800000100000005000000E0609D479AAF1141DCE4284375FD4BC1009C5A7EEBDDCEC066574A1D448B52C111DEA19A8E293A41E8A550A937FF53C1EC647D947B943B41523BEBFDA75E4EC1E0609D479AAF1141DCE4284375FD4BC1', '', NOW(), NULL, NULL, 3, NULL, 1, '', '4c1391f3-53b5-4130-b0d7-bbbdfc26fb81', '', 'READY');
-- Needed for the gen_random_uuid
CREATE EXTENSION pgcrypto;

-- Wrapping everything in a transaction so Extract won't load only part of an order
START TRANSACTION;

--- Create an Order (A rectangle, with autoincrement ID and random download uuid)
INSERT INTO "order" (
title, description, processing_fee_currency, processing_fee, total_without_vat_currency, total_without_vat, part_vat_currency, part_vat, total_with_vat_currency, total_with_vat, geom, invoice_reference, date_ordered, date_downloaded, date_processed, client_id, invoice_contact_id, order_type_id, extract_result, download_guid, email_deliver, order_status)VALUES ('Demo order ' || to_char(NOW(), 'HH:MI'), 'An order for experiments', 'CHF', NULL, 'CHF', NULL, 'CHF', NULL, 'CHF', NULL, '0103000020080800000100000005000000E0609D479AAF1141DCE4284375FD4BC1009C5A7EEBDDCEC066574A1D448B52C111DEA19A8E293A41E8A550A937FF53C1EC647D947B943B41523BEBFDA75E4EC1E0609D479AAF1141DCE4284375FD4BC1', '', NOW(), NULL, NULL, 3, NULL, 1, '', gen_random_uuid(), '', 'READY');

-- Create a relevant OrderItem order_id=CURRVAL('order_id_seq')
INSERT INTO order_item (last_download, price_status, _price_currency, _price, _base_fee_currency, _base_fee, data_format_id, order_id, product_id, extract_result, srid, status, comment, token, validation_date) VALUES (NULL, 'CALCULATED', 'CHF', 0.00, 'CHF', NULL, 1, CURRVAL('order_id_seq'), 1, '', 2056, 'PENDING', NULL, NULL, NULL);

-- Create a relevant OrderItem order_id=CURRVAL('order_id_seq')
INSERT INTO order_item (last_download, price_status, _price_currency, _price, _base_fee_currency, _base_fee, data_format_id, order_id, product_id, extract_result, srid, status, comment, token, validation_date) VALUES (NULL, 'CALCULATED', 'CHF', 0.00, 'CHF', NULL, 1, CURRVAL('order_id_seq'), 1, '', 2056, 'PENDING', NULL, NULL, NULL);

-- Create a relevant OrderItem order_id=CURRVAL('order_id_seq')
INSERT INTO order_item (last_download, price_status, _price_currency, _price, _base_fee_currency, _base_fee, data_format_id, order_id, product_id, extract_result, srid, status, comment, token, validation_date) VALUES (NULL, 'CALCULATED', 'CHF', 0.00, 'CHF', NULL, 1, CURRVAL('order_id_seq'), 1, '', 2056, 'PENDING', NULL, NULL, NULL);

END TRANSACTION;
```
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ services:
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U extractuser" -d postgres]
test: ["CMD-SHELL", "pg_isready -U extractuser -d postgres"]
interval: 5s
timeout: 5s
retries: 5
Expand Down
5 changes: 0 additions & 5 deletions geoshop/sampledata.sql
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,3 @@ INSERT INTO product_format (id, is_manual, data_format_id, product_id) VALUES (5
-- Orders
INSERT INTO order_type (id, name) VALUES (1, 'Demo order type 1');
INSERT INTO order_type (id, name) VALUES (2, 'Demo order type 2');
INSERT INTO "order" (id, title, description, processing_fee_currency, processing_fee, total_without_vat_currency, total_without_vat, part_vat_currency, part_vat, total_with_vat_currency, total_with_vat, geom, invoice_reference, date_ordered, date_downloaded, date_processed, client_id, invoice_contact_id, order_type_id, extract_result, download_guid, email_deliver, order_status) VALUES (12, 'Demo order 2', '', 'CHF', NULL, 'CHF', NULL, 'CHF', NULL, 'CHF', NULL, '01030000200808000001000000060000007BA60CC7F3024541B27B66D9BBF731417925FE3593234541B27B66D9AFF93141D824821AE4374541B27B66D9E7DF3141F424F5F25F344541B27B66D9CFB13141D326CE49D1F74441B27B66D937C231417BA60CC7F3024541B27B66D9BBF73141', '', '2024-07-12 13:23:39.124494+00', NULL, NULL, 3, NULL, 1, '', '4c1391f3-53b5-4130-b0d7-bbbdfc26fb81', '', 'READY');
INSERT INTO "order" (id, title, description, processing_fee_currency, processing_fee, total_without_vat_currency, total_without_vat, part_vat_currency, part_vat, total_with_vat_currency, total_with_vat, geom, invoice_reference, order_status, date_ordered, date_downloaded, date_processed, client_id, invoice_contact_id, order_type_id, extract_result, download_guid, email_deliver) VALUES (2, 'Demo order 1', '', 'CHF', 0.00, 'CHF', 0.00, 'CHF', 0.00, 'CHF', 0.00, '010300002008080000010000000A000000C0F0FFC3B011EFC05E86F3360C9E49C1284F59C93AE91FC163DFA461384954C1C0C467F1F07DFA40A2B22E72981455C1385F13CA67B61C41A21A4DA2FEFF4EC11ABD13C1A43F3F411D6B1542163950C1D1D6A325F4633D415B53F635624055C110E9B1E619564741671981FD680956C18D88BBBD57C64341BC00C506F4C94BC185916F3212504341CC7E2BDF8C3849C1C0F0FFC3B011EFC05E86F3360C9E49C1', '', 'READY', NULL, NULL, NULL, 3, NULL, 1, '', NULL, NULL);
INSERT INTO order_item (id, last_download, price_status, _price_currency, _price, _base_fee_currency, _base_fee, data_format_id, order_id, product_id, extract_result, srid, status, comment, token, validation_date) VALUES (14, NULL, 'CALCULATED', 'CHF', 0.00, 'CHF', NULL, 1, 11, 1, '', 2056, 'PENDING', NULL, NULL, NULL);
INSERT INTO order_item (id, last_download, price_status, _price_currency, _price, _base_fee_currency, _base_fee, data_format_id, order_id, product_id, extract_result, srid, status, comment, token, validation_date) VALUES (15, NULL, 'CALCULATED', 'CHF', 0.00, 'CHF', NULL, 1, 11, 2, '', 2056, 'PENDING', NULL, NULL, NULL);
INSERT INTO order_item (id, last_download, price_status, _price_currency, _price, _base_fee_currency, _base_fee, data_format_id, order_id, product_id, extract_result, srid, status, comment, token, validation_date) VALUES (16, NULL, 'CALCULATED', 'CHF', 0.00, 'CHF', NULL, 2, 12, 1, '', 2056, 'PENDING', '', '1', NULL);