SELECT COUNT(*) as count FROM orders WHERE status = 'confirmed';

ALTER TABLE notifications
    MODIFY COLUMN type VARCHAR(50) NOT NULL;

ALTER TABLE orders
    ADD COLUMN is_archived BOOLEAN DEFAULT FALSE;

ALTER TABLE orders
    ADD COLUMN delivery_price DECIMAL(10, 2) NOT NULL;

ALTER TABLE orders
    ADD COLUMN total_price DECIMAL(10, 2) NOT NULL;

SELECT
    o.id, o.created_at, o.status, o.phone,
    COUNT(oi.id) as items_count,
    SUM(oi.quantity * oi.price) as total_price,
    o.source
FROM
    orders o
        LEFT JOIN
    order_items oi ON o.id = oi.order_id;

ALTER TABLE products
    ADD COLUMN is_archived BOOLEAN DEFAULT FALSE,
    ADD COLUMN is_public BOOLEAN DEFAULT TRUE;

UPDATE products SET is_archived = 1 WHERE id = :id;

TRUNCATE TABLE areas;

select * from orders left join order_items on orders.id = order_items.order_id where orders.id = 1;

SELECT
    order_items.id AS item_id,
    order_items.order_id,
    order_items.product_id,
    order_items.selected_variants,
    order_items.quantity,
    order_items.price,
    products.title,
    products.thumbnail_url,
    product_options.title AS option_title,
    product_variants.variant AS variant_value
FROM order_items
         INNER JOIN products ON order_items.product_id = products.id
         LEFT JOIN product_options ON products.id = product_options.product_id
         LEFT JOIN product_variants ON product_options.id = product_variants.option_id
WHERE order_id = 26;

ALTER TABLE orders
    MODIFY COLUMN details TEXT DEFAULT 'confirmed';

ALTER TABLE orders
    ADD COLUMN is_exported BOOLEAN DEFAULT FALSE;

UPDATE orders
SET status = 'sent_to_deliver',
    is_exported = 0;

use cod_db_1;
DELETE FROM categories WHERE id = 7;



