PHP Classes

File: database/migrations/v1.11.0.39_ad_campaign_schedules.php

Recommend this page to a friend!
  Packages of Matthew Asham   Binkterm PHP   database/migrations/v1.11.0.39_ad_campaign_schedules.php   Download  
File: database/migrations/v1.11.0.39_ad_campaign_schedules.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Binkterm PHP
Bulletin board system based on the Web
Author: By
Last change:
Date: 5 days ago
Size: 816 bytes
 

Contents

Class file image Download
<?php
/**
 * Migration: 1.11.0.39 - Add explicit schedules for advertisement campaigns
 */

return function ($db) {
   
$db->exec("
        CREATE TABLE IF NOT EXISTS advertisement_campaign_schedules (
            id SERIAL PRIMARY KEY,
            campaign_id INTEGER NOT NULL REFERENCES advertisement_campaigns(id) ON DELETE CASCADE,
            days_mask INTEGER NOT NULL DEFAULT 0,
            time_of_day CHAR(5) NOT NULL DEFAULT '12:00',
            timezone VARCHAR(64) NOT NULL DEFAULT 'UTC',
            is_active BOOLEAN NOT NULL DEFAULT TRUE,
            last_triggered_at TIMESTAMPTZ DEFAULT NULL
        )
    "
);

   
$db->exec("
        CREATE INDEX IF NOT EXISTS idx_ad_campaign_schedules_campaign
            ON advertisement_campaign_schedules (campaign_id, is_active)
    "
);

    return
true;
};