drink-it-cold/sql/migrations/003_booking_times_fees.sql

15 lines
755 B
MySQL
Raw Normal View History

-- Uhrzeiten (optional) und getrennte Beträge Miete / Lieferkosten.
--
-- Die Felder entsprechen der Vorlage „Neuanlage“ aus docs/App DC.xlsx:
-- Von/Bis mit Uhrzeit sowie Miete und Lieferkosten, deren Summe der
-- Gesamtbetrag ist. Bestehende Buchungen behalten ihren Gesamtbetrag; er
-- wird als Miete übernommen, damit Miete + Lieferkosten = Gesamt gilt.
ALTER TABLE bookings
ADD COLUMN start_time TIME NULL DEFAULT NULL AFTER end_date,
ADD COLUMN end_time TIME NULL DEFAULT NULL AFTER start_time,
ADD COLUMN rent_cents INT UNSIGNED NOT NULL DEFAULT 0 AFTER deposit_cents,
ADD COLUMN delivery_cents INT UNSIGNED NOT NULL DEFAULT 0 AFTER rent_cents;
UPDATE bookings SET rent_cents = total_cents WHERE rent_cents = 0 AND total_cents > 0;