camper/demo/demo.sql

81 lines
4.4 KiB
MySQL
Raw Normal View History

-- m4_changequote(`[[', `]]')
begin;
set search_path to camper, auth, public;
alter sequence user_user_id_seq restart with 42;
insert into auth."user" (email, name, password)
values ('demo@camper', 'Demo User', 'demo')
, ('admin@camper', 'Demo Admin', 'admin')
;
alter sequence company_company_id_seq restart with 52;
insert into company (slug, business_name, vatin, trade_name, phone, email, web, address, city, province, postal_code, country_code, currency_code, default_lang_tag, legal_disclaimer)
values ('09184122-b276-4be2-9553-e4bbcbafe40d', 'Càmping les mines, S.L.U.', 'ESB17616756', 'Pescamines', parse_packed_phone_number('972 50 60 70', 'ES'), 'info@lesmines.cat', 'https://lesmines.cat/', 'C/ de lHort', 'Castelló dEmpúries', 'Girona', '17486', 'ES', 'EUR', 'ca', 'Càmping les mines, S.L.U. és responsable del tractament de les seves dades dacord amb el RGPD i la LOPDGDD, i les tracta per a mantenir una relació mercantil/comercial amb vostè. Les conservarà mentre es mantingui aquesta relació i no es comunicaran a tercers. Pot exercir els drets daccés, rectificació, portabilitat, supressió, limitació i oposició a Càmping les mines, S.L.U., amb domicili Carrer de lHort 71, 17486 Castelló dEmpúries o enviant un correu electrònic a info@lesmines.cat. Per a qualsevol reclamació pot acudir a agpd.es. Per a més informació pot consultar la nostra política de privacitat a lesmines.cat.');
insert into company_host (company_id, host)
values (52, 'localhost:8080')
, (52, 'camper.tandem.ws')
;
insert into company_user (company_id, user_id, role)
values (52, 42, 'employee')
, (52, 43, 'admin')
;
alter sequence media_media_id_seq restart with 62;
insert into media (company_id, original_filename, media_type, content)
values (52, 'plots.avif', 'image/avif', decode('m4_esyscmd([[base64 -w0 demo/plots.avif]])', 'base64'))
, (52, 'safari_tents.avif', 'image/avif', decode('m4_esyscmd([[base64 -w0 demo/safari_tents.avif]])', 'base64'))
, (52, 'bungalows.avif', 'image/avif', decode('m4_esyscmd([[base64 -w0 demo/bungalows.avif]])', 'base64'))
, (52, 'wooden_lodges.avif', 'image/avif', decode('m4_esyscmd([[base64 -w0 demo/wooden_lodges.avif]])', 'base64'))
Make home page’s carousel manageable via the database I debated with myself whether to create the home_carousel relation or rather if it would be better to have a single carousel relation for all pages. However, i thought that it would be actually harder to maintain a single relation because i would need an additional column to tell one carrousel from another, and what would that column be? An enum? A foreign key to another relation? home_carousel carries no such issues. I was starting to duplicate logic all over the packages, such as the way to encode media paths or “localization” (l10n) input fields. Therefore, i refactorized them. In the case of media path, i added a function that accepts rows of media, because always need the same columns from the row, and it was yet another repetition if i needed to pass them all the time. Plus, these kind of functions can be called as `table.function`, that make them look like columns from the table; if PostgreSQL implemented virtual generated columns, i would have used that instead. I am not sure whether that media_path function can be immutable. An immutable function is “guaranteed to return the same results given the same arguments forever”, which would be true if the inputs where the hash and the original_filename columns, instead of the whole rows, but i left it as static because i did not know whether PostgreSQL interprets the “same row but with different values” as a different input. That is, whether PostgreSQL’s concept of row is the actual tuple or the space that has a rowid, irrespective of contents; in the latter case, the function can not be immutable. Just to be in the safe side, i left it stable. The home page was starting to grow a bit too much inside the app package, new that it has its own admin handler, and moved it all to a separate package.
2023-09-14 23:05:38 +00:00
, (52, 'home_carousel0.jpg', 'image/jpeg', decode('m4_esyscmd([[base64 -w0 demo/home_carousel0.jpg]])', 'base64'))
, (52, 'home_carousel1.jpg', 'image/jpeg', decode('m4_esyscmd([[base64 -w0 demo/home_carousel1.jpg]])', 'base64'))
, (52, 'home_carousel2.jpg', 'image/jpeg', decode('m4_esyscmd([[base64 -w0 demo/home_carousel2.jpg]])', 'base64'))
, (52, 'home_carousel3.jpg', 'image/jpeg', decode('m4_esyscmd([[base64 -w0 demo/home_carousel3.jpg]])', 'base64'))
, (52, 'home_carousel4.jpg', 'image/jpeg', decode('m4_esyscmd([[base64 -w0 demo/home_carousel4.jpg]])', 'base64'))
, (52, 'home_carousel5.jpg', 'image/jpeg', decode('m4_esyscmd([[base64 -w0 demo/home_carousel5.jpg]])', 'base64'))
, (52, 'home_carousel6.jpg', 'image/jpeg', decode('m4_esyscmd([[base64 -w0 demo/home_carousel6.jpg]])', 'base64'))
, (52, 'home_carousel7.jpg', 'image/jpeg', decode('m4_esyscmd([[base64 -w0 demo/home_carousel7.jpg]])', 'base64'))
, (52, 'home_carousel8.jpg', 'image/jpeg', decode('m4_esyscmd([[base64 -w0 demo/home_carousel8.jpg]])', 'base64'))
;
insert into home_carousel (media_id, caption)
values (66, 'Volcà de Santa Margarida')
, (67, 'Gorga fosca Sadernes')
, (68, 'Castellfollit de la Roca')
, (69, 'Besalú')
, (70, 'Santa Pau')
, (71, 'Banyoles')
, (72, 'Girona')
, (73, 'Costa Brava')
, (74, 'Barcelona')
;
insert into home_carousel_i18n (media_id, lang_tag, caption)
values (66, 'en', 'Santa Margarida volcano')
, (66, 'es', 'Volcán de Santa Margarida')
, (67, 'en', 'Sadernes dark gorge')
, (67, 'es', 'Piletón oscuro Sadernes')
;
alter sequence campsite_type_campsite_type_id_seq restart with 72;
insert into campsite_type (company_id, name, media_id, description)
values (52, 'Parceŀles', 62, '')
, (52, 'Safari Tents', 63, '')
, (52, 'Bungalous', 64, '')
, (52, 'Cabanes de fusta', 65, '')
;
insert into campsite_type_i18n (campsite_type_id, lang_tag, name, description)
values (72, 'en', 'Plots', '')
, (72, 'es', 'Parcelas', '')
, (73, 'en', 'Safari Tents', '')
, (73, 'es', 'Tiendas Safari', '')
, (74, 'en', 'Bungalows', '')
, (74, 'es', 'Bungalós', '')
, (75, 'en', 'Wooden Lodges', '')
, (75, 'es', 'Cabañas de madera', '')
;
commit;