-- ============================================================
--  Growth Partners — additive migration
--  Run once:  mysql -u buylocal -p buylocal < db/growth-partners.sql
-- ============================================================

CREATE TABLE IF NOT EXISTS `growth_partners` (
  `id`          INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `name`        VARCHAR(200)     NOT NULL,
  `logo_path`   VARCHAR(500)     DEFAULT NULL,
  `website_url` VARCHAR(500)     DEFAULT NULL,
  `sort_order`  INT(11)          NOT NULL DEFAULT 0,
  `active`      TINYINT(1)       NOT NULL DEFAULT 1,
  `created_at`  DATETIME         NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at`  DATETIME         NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Placeholder rows — replace with real partner data via the admin panel
INSERT INTO `growth_partners` (`name`, `logo_path`, `website_url`, `sort_order`, `active`) VALUES
('Growth Partner One',   NULL, NULL, 10, 1),
('Growth Partner Two',   NULL, NULL, 20, 1),
('Growth Partner Three', NULL, NULL, 30, 1);

-- ============================================================
--  Growth Partners — add listing_id column
--  Run once:  mysql -u buylocal -p buylocal < db/growth-partners-alter.sql
-- ============================================================

ALTER TABLE `growth_partners`
    ADD COLUMN `listing_id` INT(10) UNSIGNED DEFAULT NULL AFTER `id`,
    ADD CONSTRAINT `fk_gp_listing`
        FOREIGN KEY (`listing_id`) REFERENCES `listings` (`id`)
        ON DELETE SET NULL ON UPDATE CASCADE;
 