<?php
use Migrations\AbstractMigration;
class Initial extends AbstractMigration
{
public $autoId = false;
public function up()
{
$this->execute("SET SESSION sql_mode = ''");
$databaseName = $this->getAdapter()->getOption('name');
try {
$this->execute("ALTER DATABASE `{$databaseName}` CHARACTER SET utf8 COLLATE utf8_general_ci;");
} catch (\Exception $exception) {
}
$this->table('campaign_items')
->addColumn('id', 'integer', [
'autoIncrement' => true,
'default' => null,
'limit' => 10,
'null' => false,
'signed' => false,
])
->addPrimaryKey(['id'])
->addColumn('campaign_id', 'integer', [
'default' => 0,
'limit' => 10,
'null' => false,
])
->addColumn('country', 'string', [
'default' => '',
'limit' => 256,
'null' => false,
])
->addColumn('advertiser_price', 'float', [
'default' => 0,
'null' => false,
'precision' => 50,
'scale' => 6,
])
->addColumn('publisher_price', 'float', [
'default' => 0,
'null' => false,
'precision' => 50,
'scale' => 6,
])
->addColumn('purchase', 'integer', [
'default' => 0,
'limit' => 10,
'null' => false,
])
->addColumn('views', 'integer', [
'default' => 0,
'limit' => 10,
'null' => false,
'signed' => false,
])
->addColumn('weight', 'float', [
'default' => 0,
'limit' => null,
'null' => false,
])
->create();
$this->table('campaigns')
->addColumn('id', 'integer', [
'autoIncrement' => true,
'default' => null,
'limit' => 10,
'null' => false,
'signed' => false,
])
->addPrimaryKey(['id'])
->addColumn('default_campaign', 'boolean', [
'default' => 0,
'limit' => null,
'null' => false,
])
->addColumn('user_id', 'integer', [
'default' => 0,
'limit' => 10,
'null' => false,
'signed' => false,
])
->addColumn('ad_id', 'integer', [
'default' => 0,
'limit' => 10,
'null' => false,
'signed' => false,
])
->addColumn('status', 'string', [
'comment' => 'Under Review, Pending Payment, Canceled Payment, Invalid Payment, Refunded, Active, Paused, Finished, Canceled',
'default' => '',
'limit' => 256,
'null' => false,
])
->addColumn('title', 'string', [
'default' => '',
'limit' => 256,
'null' => false,
])
->addColumn('url', 'string', [
'default' => '',
'limit' => 256,
'null' => false,
])
->addColumn('price', 'float', [
'default' => 0,
'null' => false,
'precision' => 50,
'scale' => 6,
])
->addColumn('transaction_id', 'string', [
'default' => '',
'limit' => 256,
'null' => false,
])
->addColumn('transaction_details', 'text', [
'default' => null,
'limit' => null,
'null' => true,
])
->addColumn('started', 'datetime', [
'default' => null,
'limit' => null,
'null' => true,
])
->addColumn('completed', 'datetime', [
'default' => null,
'limit' => null,
'null' => true,
])
->addColumn('modified', 'datetime', [
'default' => null,
'limit' => null,
'null' => true,
])
->addColumn('created', 'datetime', [
'default' => null,
'limit' => null,
'null' => true,
])
->create();
$this->table('links')
->addColumn('id', 'integer', [
'autoIncrement' => true,
'default' => null,
'limit' => 10,
'null' => false,
'signed' => false,
])
->addPrimaryKey(['id'])
->addColumn('user_id', 'integer', [
'default' => 0,
'limit' => 10,
'null' => false,
'signed' => false,
])
->addColumn('ad_id', 'integer', [
'comment' => '\'Interstitial Advertisement ($$$$$)\',\'Framed Banner ($$$)\',\'No Advert\'',
'default' => 0,
'limit' => 10,
'null' => false,
'signed' => false,
])
->addColumn('status', 'string', [
'comment' => 'active,inactive,hidden',
'default' => '',
'limit' => 256,
'null' => false,
])
->addColumn('url', 'string', [
'default' => '',
'limit' => 500,
'null' => false,
])
->addColumn('alias', 'string', [
'default' => '',
'limit' => 256,
'null' => false,
])
->addColumn('title', 'string', [
'default' => '',
'limit' => 200,
'null' => false,
])
->addColumn('description', 'text', [
'default' => null,
'limit' => null,
'null' => true,
])
->addColumn('hits', 'integer', [
'default' => 0,
'limit' => 11,
'null' => false,
'signed' => false,
])
->addColumn('modified', 'datetime', [
'default' => null,
'limit' => null,
'null' => true,
])
->addColumn('created', 'datetime', [
'default' => null,
'limit' => null,
'null' => true,
])
->create();
$this->table('options')
->addColumn('id', 'integer', [
'autoIncrement' => true,
'default' => null,
'limit' => 10,
'null' => false,
'signed' => false,
])
->addPrimaryKey(['id'])
->addColumn('name', 'string', [
'default' => '',
'limit' => 256,
'null' => false,
])
->addColumn('value', 'text', [
'default' => null,
'limit' => 4294967295,
'null' => true,
])
->create();
$this->table('pages')
->addColumn('id', 'integer', [
'autoIncrement' => true,
'default' => null,
'limit' => 10,
'null' => false,
'signed' => false,
])
->addPrimaryKey(['id'])
->addColumn('title', 'string', [
'default' => '',
'limit' => 256,
'null' => false,
])
->addColumn('slug', 'string', [
'default' => '',
'limit' => 256,
'null' => false,
])
->addColumn('published', 'integer', [
'default' => 0,
'limit' => 2,
'null' => false,
])
->addColumn('content', 'text', [
'default' => null,
'limit' => 4294967295,
'null' => true,
])
->addColumn('modified', 'datetime', [
'default' => null,
'limit' => null,
'null' => true,
])
->addColumn('created', 'datetime', [
'default' => null,
'limit' => null,
'null' => true,
])
->create();
$this->table('statistics')
->addColumn('id', 'integer', [
'autoIncrement' => true,
'default' => null,
'limit' => 10,
'null' => false,
'signed' => false,
])
->addPrimaryKey(['id'])
->addColumn('link_id', 'integer', [
'default' => 0,
'limit' => 10,
'null' => false,
'signed' => false,
])
->addColumn('user_id', 'integer', [
'default' => 0,
'limit' => 10,
'null' => false,
'signed' => false,
])
->addColumn('ad_id', 'integer', [
'default' => 0,
'limit' => 10,
'null' => false,
'signed' => false,
])
->addColumn('campaign_id', 'integer', [
'default' => 0,
'limit' => 10,
'null' => false,
'signed' => false,
])
->addColumn('campaign_user_id', 'integer', [
'default' => 0,
'limit' => 10,
'null' => false,
'signed' => false,
])
->addColumn('campaign_item_id', 'integer', [
'default' => 0,
'limit' => 10,
'null' => false,
'signed' => false,
])
->addColumn('ip', 'string', [
'default' => '',
'limit' => 256,
'null' => false,
])
->addColumn('country', 'string', [
'default' => '',
'limit' => 256,
'null' => false,
])
->addColumn('owner_earn', 'float', [
'default' => 0,
'null' => false,
'precision' => 50,
'scale' => 6,
])
->addColumn('publisher_earn', 'float', [
'default' => 0,
'null' => false,
'precision' => 50,
'scale' => 6,
])
->addColumn('referer_domain', 'string', [
'default' => '',
'limit' => 256,
'null' => false,
])
->addColumn('referer', 'string', [
'default' => '',
'limit' => 256,
'null' => false,
])
->addColumn('user_agent', 'string', [
'default' => '',
'limit' => 256,
'null' => false,
])
->addColumn('created', 'datetime', [
'default' => null,
'limit' => null,
'null' => true,
])
->create();
$this->table('users')
->addColumn('id', 'integer', [
'autoIncrement' => true,
'default' => null,
'limit' => 10,
'null' => false,
'signed' => false,
])
->addPrimaryKey(['id'])
->addColumn('status', 'string', [
'comment' => 'active,inactive,pending',
'default' => '',
'limit' => 256,
'null' => false,
])
->addColumn('username', 'string', [
'default' => '',
'limit' => 256,
'null' => false,
])
->addColumn('password', 'string', [
'default' => '',
'limit' => 256,
'null' => false,
])
->addColumn('email', 'string', [
'default' => '',
'limit' => 256,
'null' => false,
])
->addColumn('temp_email', 'string', [
'default' => '',
'limit' => 256,
'null' => false,
])
->addColumn('role', 'string', [
'default' => '',
'limit' => 20,
'null' => false,
])
->addColumn('api_token', 'string', [
'default' => '',
'limit' => 256,
'null' => false,
])
->addColumn('activation_key', 'string', [
'default' => '',
'limit' => 256,
'null' => false,
])
->addColumn('advertiser_balance', 'float', [
'default' => 0,
'null' => false,
'precision' => 50,
'scale' => 6,
'signed' => false,
])
->addColumn('publisher_balance', 'float', [
'default' => 0,
'null' => false,
'precision' => 50,
'scale' => 6,
'signed' => false,
])
->addColumn('first_name', 'string', [
'default' => '',
'limit' => 256,
'null' => false,
])
->addColumn('last_name', 'string', [
'default' => '',
'limit' => 256,
'null' => false,
])
->addColumn('address1', 'string', [
'default' => '',
'limit' => 256,
'null' => false,
])
->addColumn('address2', 'string', [
'default' => '',
'limit' => 256,
'null' => false,
])
->addColumn('city', 'string', [
'default' => '',
'limit' => 256,
'null' => false,
])
->addColumn('state', 'string', [
'default' => '',
'limit' => 256,
'null' => false,
])
->addColumn('zip', 'string', [
'default' => '',
'limit' => 256,
'null' => false,
])
->addColumn('country', 'string', [
'default' => '',
'limit' => 256,
'null' => false,
])
->addColumn('phone_number', 'string', [
'default' => '',
'limit' => 256,
'null' => false,
])
->addColumn('withdrawal_method', 'string', [
'default' => '',
'limit' => 256,
'null' => false,
])
->addColumn('withdrawal_email', 'string', [
'default' => '',
'limit' => 256,
'null' => false,
])
->addColumn('modified', 'datetime', [
'default' => null,
'limit' => null,
'null' => true,
])
->addColumn('created', 'datetime', [
'default' => null,
'limit' => null,
'null' => true,
])
->create();
$this->table('withdraws')
->addColumn('id', 'integer', [
'autoIncrement' => true,
'default' => null,
'limit' => 10,
'null' => false,
'signed' => false,
])
->addPrimaryKey(['id'])
->addColumn('user_id', 'integer', [
'default' => 0,
'limit' => 10,
'null' => false,
'signed' => false,
])
->addColumn('status', 'string', [
'default' => '',
'limit' => 256,
'null' => false,
])
->addColumn('amount', 'float', [
'default' => 0,
'null' => false,
'precision' => 50,
'scale' => 6,
])
->addColumn('transaction_id', 'string', [
'default' => '',
'limit' => 256,
'null' => false,
])
->addColumn('created', 'datetime', [
'default' => null,
'limit' => null,
'null' => true,
])
->create();
}
public function down()
{
$this->execute("SET SESSION sql_mode = ''");
$this->dropTable('campaign_items');
$this->dropTable('campaigns');
$this->dropTable('links');
$this->dropTable('options');
$this->dropTable('pages');
$this->dropTable('statistics');
$this->dropTable('users');
$this->dropTable('withdraws');
}
}