-- +goose Up
-- +goose StatementBegin

UPDATE rental_listings l
JOIN rental_orders o ON o.listing_id = l.id
SET l.status = 'completed',
    l.in_transaction = 0,
    l.published_at = NULL
WHERE o.status = 'completed'
  AND l.status = 'offline';

-- +goose StatementEnd

-- +goose Down
-- +goose StatementBegin

UPDATE rental_listings l
JOIN rental_orders o ON o.listing_id = l.id
SET l.status = 'offline',
    l.in_transaction = 0,
    l.published_at = NULL
WHERE o.status = 'completed'
  AND l.status = 'completed';

-- +goose StatementEnd
