From 2ad6ccf1e6d95affd49d47bf1366fb76802314d3 Mon Sep 17 00:00:00 2001 From: marsalva Date: Fri, 3 Apr 2026 21:13:42 +0000 Subject: [PATCH] Actualizar server.js --- server.js | 48 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/server.js b/server.js index 7da97e5..51f1bec 100644 --- a/server.js +++ b/server.js @@ -325,21 +325,39 @@ async function autoUpdateDB() { ); CREATE TABLE IF NOT EXISTS protection_subscriptions ( - id SERIAL PRIMARY KEY, - company_id INT REFERENCES users(id) ON DELETE CASCADE, - plan_id INT REFERENCES protection_plans(id) ON DELETE RESTRICT, - client_name TEXT NOT NULL, - client_dni TEXT, - client_phone TEXT, - payment_status TEXT DEFAULT 'pagado', - status TEXT DEFAULT 'activo', - custom_discount INT DEFAULT 0, - bricos_used INT DEFAULT 0, - urgencies_used INT DEFAULT 0, - renewal_date DATE, - contract_pdf_url TEXT, - created_at TIMESTAMP DEFAULT NOW() - ); + id SERIAL PRIMARY KEY, + company_id INT REFERENCES users(id) ON DELETE CASCADE, + plan_id INT REFERENCES protection_plans(id) ON DELETE RESTRICT, + client_name TEXT NOT NULL, + client_dni TEXT, + client_phone TEXT, + + payment_status TEXT DEFAULT 'impagado', + status TEXT DEFAULT 'pendiente_pago', + + custom_discount INT DEFAULT 0, + bricos_used INT DEFAULT 0, + urgencies_used INT DEFAULT 0, + + renewal_date DATE, + contract_pdf_url TEXT, + + stripe_session_id TEXT, + stripe_subscription_id TEXT, + stripe_customer_id TEXT, + stripe_price_id TEXT, + + started_at TIMESTAMP, + current_period_start TIMESTAMP, + current_period_end TIMESTAMP, + last_payment_at TIMESTAMP, + cancel_at_period_end BOOLEAN DEFAULT FALSE, + cancelled_at TIMESTAMP, + ended_at TIMESTAMP, + updated_at TIMESTAMP DEFAULT NOW(), + + created_at TIMESTAMP DEFAULT NOW() +); CREATE TABLE IF NOT EXISTS protection_activity ( id SERIAL PRIMARY KEY,