Compare commits

...

2 Commits

Author SHA1 Message Date
f9ce4a6978 Updated for gitea 2024-07-03 12:25:34 +10:00
a95548e455 Redo database migrations for pgsql 2024-07-03 12:15:40 +10:00
117 changed files with 4120 additions and 3469 deletions

View File

@ -8,12 +8,13 @@ APP_URL=https://www.graytech.net.au
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=database
DB_PORT=3306
DB_DATABASE=database
DB_USERNAME=homestead
DB_PASSWORD=secret
DB_CONNECTION=pgsql
DB_HOST=postgres
DB_PORT=5432
DB_DATABASE=graytech
DB_USERNAME=graytech
DB_PASSWORD=
DB_SCHEMA=billing
BROADCAST_DRIVER=log
CACHE_DRIVER=file

View File

@ -0,0 +1,147 @@
name: Create Docker Image
run-name: ${{ gitea.actor }} Building Docker Image 🐳
on: [push]
env:
VERSION: latest
DOCKER_HOST: tcp://127.0.0.1:2375
jobs:
# test:
# strategy:
# matrix:
# arch:
# - x86_64
# # arm64
#
# name: Test Application
# runs-on: docker-${{ matrix.arch }}
# container:
# image: gitea.dege.au/docker/php:8.3-fpm-pgsql-server-test
#
# steps:
# - name: Environment Setup
# run: |
# # If we have a proxy use it
# if [ -n "${HTTP_PROXY}" ]; then echo "HTTP PROXY [${HTTP_PROXY}]"; sed -i -e s'/https/http/' /etc/apk/repositories; fi
# # Some pre-reqs
# apk add git nodejs
# ## Some debugging info
# # env|sort
#
# - name: Code Checkout
# uses: actions/checkout@v4
#
# - name: Run Tests
# run: |
# mv .env.testing .env
# # Install Composer and project dependencies.
# mkdir -p ${COMPOSER_HOME}
# if [ -n "${{ secrets.COMPOSER_GITHUB_TOKEN }}" ]; then echo ${{ secrets.COMPOSER_GITHUB_TOKEN }} > ${COMPOSER_HOME}/auth.json; fi
# composer install
# # Generate an application key. Re-cache.
# php artisan key:generate
# php artisan migrate
# php artisan db:seed
# # run laravel tests
# touch storage/app/test/*ZIP storage/app/test/file/*
# XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-text --colors=never
build:
strategy:
matrix:
arch:
- x86_64
# - arm64
# needs: [test]
name: Build Docker Image
runs-on: docker-${{ matrix.arch }}
container:
image: docker:dind
privileged: true
env:
ARCH: ${{ matrix.arch }}
VERSIONARCH: ${{ env.VERSION }}-${{ env.ARCH }}
steps:
- name: Environment Setup
run: |
# If we have a proxy use it
if [ -n "${HTTP_PROXY}" ]; then echo "HTTP PROXY [${HTTP_PROXY}]"; sed -i -e s'/https/http/' /etc/apk/repositories; fi
# Some pre-reqs
apk add git curl nodejs
# Start docker
( dockerd --host=tcp://0.0.0.0:2375 --tls=false & ) && sleep 3
## Some debugging info
# docker info && docker version
env|sort
echo "PRT: ${{ secrets.PKG_WRITE_TOKEN }}"
- name: Registry FQDN Setup
id: registry
run: |
registry=${{ github.server_url }}
echo "registry=${registry##http*://}" >> "$GITHUB_OUTPUT"
- name: Container Registry Login
uses: docker/login-action@v2
with:
registry: ${{ steps.registry.outputs.registry }}
username: ${{ gitea.actor }}
password: ${{ secrets.PKG_WRITE_TOKEN }}
- name: Code Checkout
uses: actions/checkout@v4
- name: Record version
run: |
pwd
ls -al
echo ${GITHUB_SHA::8} > VERSION
cat VERSION
- name: Build and Push Docker Image
uses: docker/build-push-action@v5
with:
context: .
file: docker/Dockerfile
push: true
tags: "${{ steps.registry.outputs.registry }}/${{ env.GITHUB_REPOSITORY }}:${{ env.VERSIONARCH }}"
manifest:
name: Final Docker Image Manifest
runs-on: docker-x86_64
container:
image: docker:dind
privileged: true
needs: [build]
steps:
- name: Environment Setup
run: |
# If we have a proxy use it
if [ -n "${HTTP_PROXY}" ]; then echo "HTTP PROXY [${HTTP_PROXY}]"; sed -i -e s'/https/http/' /etc/apk/repositories; fi
# Some pre-reqs
apk add git curl nodejs
# Start docker
( dockerd --host=tcp://0.0.0.0:2375 --tls=false & ) && sleep 3
- name: Registry FQDN Setup
id: registry
run: |
registry=${{ github.server_url }}
echo "registry=${registry##http*://}" >> "$GITHUB_OUTPUT"
- name: Container Registry Login
uses: docker/login-action@v2
with:
registry: ${{ steps.registry.outputs.registry }}
username: ${{ gitea.actor }}
password: ${{ secrets.PKG_WRITE_TOKEN }}
- name: Build Docker Manifest
run: |
docker manifest create ${{ steps.registry.outputs.registry }}/${{ env.GITHUB_REPOSITORY }}:${{ env.VERSION }} \
${{ steps.registry.outputs.registry }}/${{ env.GITHUB_REPOSITORY }}:${{ env.VERSION }}-x86_64 \
${{ steps.registry.outputs.registry }}/${{ env.GITHUB_REPOSITORY }}:${{ env.VERSION }}-arm64
docker manifest push --purge ${{ steps.registry.outputs.registry }}/${{ env.GITHUB_REPOSITORY }}:${{ env.VERSION }}

View File

@ -1,14 +0,0 @@
stages:
- test
- build
# This folder is cached between builds
# http://docs.gitlab.com/ce/ci/yaml/README.html#cache
cache:
key: ${CI_JOB_NAME_SLUG}-${CI_COMMIT_REF_SLUG}
paths:
- vendor/
include:
- .gitlab-test.yml
- .gitlab-docker-x86_64.yml

View File

@ -1,27 +0,0 @@
docker:
variables:
VERSION: latest
DOCKER_HOST: tcp://docker:2375
stage: build
image: docker:latest
services:
- docker:dind
before_script:
- docker info && docker version
- echo "$CI_JOB_TOKEN" | docker login -u "$CI_REGISTRY_USER" "$CI_REGISTRY" --password-stdin
- if [ -n "$GITHUB_TOKEN" ]; then cat $GITHUB_TOKEN |base64 -d > auth.json; fi
script:
- if [ -f init ]; then chmod 500 init; fi
- echo -n ${CI_COMMIT_SHORT_SHA} > VERSION
- rm -rf vendor/ database/schema database/seeders database/factories/*
- docker build -t ${CI_REGISTRY_IMAGE}:${VERSION} .
- docker push ${CI_REGISTRY_IMAGE}:${VERSION}
tags:
- docker
- x86_64
only:
- master

View File

@ -1,48 +0,0 @@
test:
image: ${CI_REGISTRY}/leenooks/php:8.1-fpm-alpine-mysql-test
stage: test
# NOTE: This service is dependant on project file configuration, which is not there if the cache was deleted
# resulting in the testing to fail on the first run.
services:
- mariadb:10.5
variables:
MYSQL_DATABASE: testing
MYSQL_ROOT_PASSWORD: test
MYSQL_USER: test
MYSQL_PASSWORD: test
tags:
- php
only:
- master
- test
before_script:
- mv .env.testing .env
# Install Composer and project dependencies.
- mkdir -p ${COMPOSER_HOME}
- if [ -n "$GITHUB_TOKEN" ]; then cat $GITHUB_TOKEN |base64 -d > ${COMPOSER_HOME}/auth.json; fi
- composer install
# Add mysql client for schema pre-load
- apt update -o Acquire::ForceIPv4=true && apt install -o Acquire::ForceIPv4=true -y mariadb-client
# Generate an application key. Re-cache.
- php artisan key:generate --env=testing
- php artisan config:cache --env=testing
- php artisan migrate
- php artisan db:seed
script:
# run laravel tests
- XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-text --colors=never
# run frontend tests
# if you have any task for testing frontend
# set it in your package.json script
# comment this out if you don't have a frontend test
# npm test

View File

@ -74,7 +74,7 @@ return [
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
'schema' => 'public',
'schema' => env('DB_SCHEMA', 'public'),
'sslmode' => 'prefer',
],

View File

@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('currencies', function(Blueprint $table)
{
$table->id();
$table->boolean('active')->default(false);
$table->string('iso', 3)->unique();
$table->string('name', 191)->unique();
$table->text('notes')->nullable();
$table->text('rates')->nullable();
$table->string('symbol', 2);
$table->smallInteger('rounding');
$table->unique(['id','iso']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('currencies');
}
};

View File

@ -0,0 +1,44 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('countries', function(Blueprint $table)
{
$table->id();
$table->boolean('active')->default(false);
$table->string('name', 191)->unique();
$table->text('notes')->nullable();
$table->string('two_code', 2)->nullable()->unique();
$table->string('three_code', 3)->unique();
$table->integer('currency_id')->unsigned()->nullable();
$table->foreign(['currency_id'])->references(['id'])->on('currencies');
$table->unique(['id','currency_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('countries');
}
};

View File

@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('languages', function(Blueprint $table)
{
$table->id();
$table->string('name', 45)->nullable()->unique();
$table->string('iso', 5)->nullable()->unique();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('languages');
}
};

View File

@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('taxes', function(Blueprint $table)
{
$table->id();
$table->string('zone',128)->nullable();
$table->text('description');
$table->float('rate', 10, 0);
$table->integer('country_id')->unsigned();
$table->foreign(['country_id'])->references(['id'])->on('countries');
$table->unique(['id','country_id']);
$table->unique(['country_id','zone']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('taxes');
}
};

View File

@ -0,0 +1,46 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('sites', function(Blueprint $table)
{
$table->id();
$table->integer('site_id')->unsigned();
$table->boolean('active')->default(false);
$table->integer('admin_id')->unsigned()->nullable();
$table->string('url',256)->unique();
$table->integer('country_id');
$table->integer('currency_id');
$table->foreign(['country_id','currency_id'])->references(['id','currency_id'])->on('countries');
$table->integer('language_id');
$table->foreign('language_id')->references('id')->on('languages');
$table->unique(['id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('sites');
}
};

View File

@ -1,7 +1,7 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
@ -13,8 +13,15 @@ return new class extends Migration
*/
public function up()
{
Schema::table('supplier_user', function (Blueprint $table) {
$table->unique(['supplier_id','id']);
Schema::create('site_details', function (Blueprint $table)
{
$table->string('key');
$table->string('value');
$table->integer('site_id')->unsigned();
$table->foreign('site_id')->references('id')->on('sites');
$table->unique(['site_id','key']);
});
}
@ -25,8 +32,6 @@ return new class extends Migration
*/
public function down()
{
Schema::table('supplier_user', function (Blueprint $table) {
$table->dropUnique(['supplier_id','id']);
});
Schema::dropIfExists('site_details');
}
};

View File

@ -0,0 +1,73 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function(Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active')->default(false);
$table->string('email', 256);
$table->string('password', 191)->nullable();
$table->string('remember_token', 100)->nullable();
$table->string('title', 8)->nullable();
$table->string('firstname', 128);
$table->string('lastname', 128);
$table->string('address1', 128)->nullable();
$table->string('address2', 128)->nullable();
$table->string('city', 128)->nullable();
$table->string('state', 64)->nullable();
$table->string('postcode', 16)->nullable();
$table->boolean('emailable')->default(1);
$table->foreign(['site_id'])->references(['id'])->on('sites');
$table->integer('country_id')->unsigned();
$table->foreign(['country_id'])->references(['id'])->on('countries');
$table->integer('language_id')->unsigned()->nullable();
$table->foreign(['language_id'])->references(['id'])->on('languages');
$table->unique(['id','site_id']);
$table->integer('parent_id')->unsigned()->nullable();
$table->foreign(['parent_id','site_id'])->references(['id','site_id'])->on('users');
$table->unique(['site_id','email']);
});
/*
*/
Schema::table('sites', function(Blueprint $table) {
$table->foreign(['admin_id','site_id'])->references(['id','site_id'])->on('users');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
/*
*/
Schema::table('sites', function(Blueprint $table) {
$table->dropForeign(['admin_id','site_id']);
});
Schema::drop('users');
}
};

View File

@ -0,0 +1,43 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('provider_oauth', function(Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active')->default(false);
$table->string('name',32);
$table->string('app_id',128);
$table->string('secret',128);
$table->foreign(['site_id'])->references(['id'])->on('sites');
$table->unique(['id','site_id']);
$table->unique(['site_id','name']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('provider_oauth');
}
};

View File

@ -0,0 +1,47 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('groups', function(Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active')->default(false);
$table->dateTime('start_at')->nullable();
$table->dateTime('expire_at')->nullable();
$table->string('name',128)->unique();
$table->boolean('pricing')->default(false);
$table->text('notes')->nullable();
$table->foreign(['site_id'])->references(['id'])->on('sites');
$table->unique(['id','site_id']);
$table->integer('parent_id')->nullable();
$table->foreign(['parent_id','site_id'])->references(['id','site_id'])->on('groups');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('groups');
}
};

View File

@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('rtm', function(Blueprint $table)
{
$table->id();
$table->integer('site_id')->unsigned();
$table->string('name',64)->unique();
$table->integer('account_id')->unsigned();
$table->foreign(['site_id'])->references(['id'])->on('sites');
$table->unique(['id','site_id']);
$table->integer('parent_id')->unsigned()->nullable();
$table->foreign(['parent_id','site_id'])->references(['id','site_id'])->on('rtm');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('rtm');
}
};

View File

@ -0,0 +1,67 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('accounts', function(Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active')->default(false);
$table->date('expire_at')->nullable();
$table->string('company')->nullable();
$table->string('address1', 128)->nullable();
$table->string('address2', 128)->nullable();
$table->string('city', 32)->nullable();
$table->string('state', 32)->nullable();
$table->string('zip', 16)->nullable();
$table->integer('country_id')->unsigned();
$table->foreign(['country_id'])->references(['id'])->on('countries');
$table->integer('rtm_id')->unsigned();
$table->foreign(['rtm_id','site_id'])->references(['id','site_id'])->on('rtm');
$table->integer('user_id')->unsigned();
$table->foreign(['user_id','site_id'])->references(['id','site_id'])->on('users');
$table->unique(['id','site_id']);
});
/*
*/
Schema::table('rtm', function(Blueprint $table) {
$table->foreign(['account_id','site_id'])->references(['id','site_id'])->on('accounts');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
/*
*/
Schema::table('rtm', function(Blueprint $table)
{
$table->dropForeign(['account_id','site_id']);
$table->dropColumn('account_id');
});
Schema::drop('accounts');
}
};

View File

@ -0,0 +1,46 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('account_group', function(Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active')->default(false);
$table->dateTime('start_at')->nullable();
$table->dateTime('expire_at')->nullable();
$table->integer('account_id')->unsigned();
$table->foreign(['account_id','site_id'])->references(['id','site_id'])->on('accounts');
$table->integer('group_id')->unsigned();
$table->foreign(['group_id','site_id'])->references(['id','site_id'])->on('groups');
$table->unique(['id','site_id']);
$table->unique(['site_id','group_id','account_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('account_group');
}
};

View File

@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('tlds',function (Blueprint $table)
{
$table->id();
$table->timestamps();
$table->string('name',64)->unique();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('tlds');
}
};

View File

@ -0,0 +1,44 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('domain_registrars', function(Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active')->default(false);
$table->string('name',32);
$table->string('file',32)->nullable();
$table->string('whitelabel_url', 256)->nullable();
$table->string('whitelabel_ns', 1024)->nullable();
$table->string('manage_url', 256)->nullable();
$table->foreign(['site_id'])->references(['id'])->on('sites');
$table->unique(['id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('domain_registrars');
}
};

View File

@ -0,0 +1,46 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('products', function(Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active')->default(false);
$table->boolean('taxable')->default(true);
$table->integer('position')->nullable();
$table->text('pricing');
$table->integer('price_recur_default')->nullable();
$table->boolean('price_recur_strict')->nullable();
$table->integer('model_id');
$table->string('model')->nullable();
$table->foreign(['site_id'])->references(['id'])->on('sites');
$table->unique(['id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('products');
}
};

View File

@ -0,0 +1,65 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('services', function(Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active')->default(false);
$table->boolean('suspend_billing')->default(false);
$table->boolean('external_billing')->default(false);
$table->float('price', 10, 0)->nullable();
$table->float('price_override', 10, 0)->nullable();
$table->boolean('taxable')->default(true);
$table->integer('recur_schedule')->nullable();
$table->text('prod_attr')->nullable();
$table->string('model')->nullable();
$table->string('order_status')->nullable();
$table->text('order_info')->nullable();
$table->date('invoice_last_at')->nullable();
$table->date('invoice_next_at')->nullable();
$table->date('start_at')->nullable();
$table->date('stop_at')->nullable();
$table->integer('account_billing_id')->unsigned()->nullable(); // @todo To remove?
$table->integer('account_id')->unsigned();
$table->foreign(['account_id','site_id'])->references(['id','site_id'])->on('accounts');
$table->integer('ordered_by')->unsigned()->nullable();
$table->foreign(['ordered_by','site_id'])->references(['id','site_id'])->on('users');
$table->integer('product_id')->unsigned();
$table->foreign(['product_id','site_id'])->references(['id','site_id'])->on('products');
$table->unique(['id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('services');
}
};

View File

@ -0,0 +1,45 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('product_translate', function(Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->string('name_short',128);
$table->text('name_detail')->nullable();
$table->text('description')->nullable();
$table->integer('language_id')->unsigned();
$table->foreign(['language_id'])->references(['id'])->on('languages');
$table->integer('product_id')->unsigned();
$table->foreign(['product_id','site_id'])->references(['id','site_id'])->on('products');
$table->unique(['product_id','language_id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('product_translate');
}
};

View File

@ -0,0 +1,50 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('service__change', function(Blueprint $table)
{
$table->id();
$table->timestamps();
$table->boolean('active')->default(false);
$table->integer('site_id')->unsigned();
$table->boolean('complete')->default(false);
$table->date('ordered_at');
$table->date('effective_at')->nullable();
$table->text('notes')->nullable();
$table->integer('product_id')->unsigned();
$table->foreign(['product_id','site_id'])->references(['id','site_id'])->on('products');
$table->integer('service_id')->unsigned();
$table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services');
$table->integer('ordered_by')->unsigned();
$table->foreign(['ordered_by','site_id'])->references(['id','site_id'])->on('users');
$table->unique(['id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('service__change');
}
};

View File

@ -0,0 +1,61 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('charges', function(Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active')->default(false);
$table->boolean('processed')->default(false);
$table->integer('sweep_type')->nullable();
$table->integer('type')->nullable();
$table->float('amount', 10, 0)->nullable();
$table->float('quantity', 10, 0)->nullable();
$table->boolean('taxable')->default(true);
$table->binary('attributes', 65535)->nullable();
$table->string('description', 128)->nullable();
$table->date('start_at')->nullable();
$table->date('stop_at')->nullable();
$table->date('charge_at')->nullable();
$table->integer('account_id')->unsigned();
$table->foreign(['account_id','site_id'])->references(['id','site_id'])->on('accounts');
$table->integer('product_id')->unsigned()->nullable();
$table->foreign(['product_id','site_id'])->references(['id','site_id'])->on('products');
$table->integer('service_id')->unsigned()->nullable();
$table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services');
$table->integer('user_id')->unsigned()->nullable();
$table->foreign(['user_id','site_id'])->references(['id','site_id'])->on('users');
$table->unique(['id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('charges');
}
};

View File

@ -0,0 +1,83 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('suppliers', function (Blueprint $table)
{
$table->id();
$table->timestamps();
$table->boolean('active')->default(false);
$table->string('name')->unique();
$table->string('address1')->nullable();
$table->string('address2')->nullable();
$table->string('city')->nullable();
$table->string('state')->nullable();
$table->string('postcode',16)->nullable();
$table->date('usage_last')->nullable();
});
Schema::create('supplier_details', function (Blueprint $table)
{
$table->id();
$table->timestamps();
$table->text('notes')->nullable();
$table->string('accounts')->nullable();
$table->string('support')->nullable();
$table->string('payments')->nullable();
$table->jsonb('connections')->nullable();
$table->integer('site_id')->unsigned();
$table->foreign('site_id')->references('id')->on('sites');
$table->integer('supplier_id')->unsigned();
$table->foreign('supplier_id')->references('id')->on('suppliers');
$table->unique(['id','site_id']);
$table->unique(['site_id','supplier_id']);
});
Schema::create('supplier_user', function (Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active')->default(false);
$table->integer('supplier_id')->unsigned();
$table->foreign(['supplier_id'])->references(['id'])->on('suppliers');
$table->integer('user_id')->unsigned();
$table->foreign(['user_id','site_id'])->references(['id','site_id'])->on('users');
$table->unique(['id','site_id']);
$table->unique(['id','supplier_id']);
$table->unique(['supplier_id','user_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('supplier_user');
Schema::dropIfExists('supplier_details');
Schema::dropIfExists('suppliers');
}
};

View File

@ -0,0 +1,45 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('costs', function (Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active')->default(false);
$table->date('billed_at');
$table->string('invoice_num')->nullable();
$table->foreign(['site_id'])->references(['id'])->on('sites');
$table->integer('supplier_id')->unsigned();
$table->foreign(['supplier_id'])->references(['id'])->on('suppliers');
$table->unique(['id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('costs');
}
};

View File

@ -0,0 +1,52 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('supplier_host_servers', function(Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active')->default(false);
$table->boolean('debug')->nullable();
$table->string('name',128);
$table->string('notes')->nullable();
$table->string('provision_plugin', 128)->nullable();
$table->text('provision_plugin_data')->nullable();
$table->integer('max_accounts')->nullable();
$table->string('whitelabel_url', 256)->nullable();
$table->string('manage_url', 256)->nullable();
$table->string('manage_username', 45)->nullable();
$table->string('manage_password', 45)->nullable();
$table->foreign(['site_id'])->references(['id'])->on('sites');
$table->integer('supplier_id')->unsigned()->nullable();
$table->foreign(['supplier_id'])->references(['id'])->on('suppliers');
$table->unique(['id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('supplier_host_servers');
}
};

View File

@ -0,0 +1,87 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('supplier_email', function (Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active')->default(false);
$table->string('product_id');
$table->string('product_desc')->nullable();
$table->float('base_cost');
$table->float('setup_cost')->nullable();
$table->integer('contract_term')->nullable();
$table->integer('supplier_detail_id')->unsigned();
$table->foreign(['supplier_detail_id','site_id'])->references(['id','site_id'])->on('supplier_details');
$table->unique(['id','site_id']);
});
Schema::create('product_email', function (Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active')->default(false);
;
$table->string('product_id');
$table->string('product_desc')->nullable();
$table->float('base_cost');
$table->float('setup_cost')->nullable();
$table->integer('contract_term')->nullable();
$table->integer('supplier_item_id')->unsigned();
$table->foreign(['supplier_item_id','site_id'])->references(['id','site_id'])->on('supplier_email');
$table->unique(['id','site_id']);
});
Schema::create('service_email', function (Blueprint $table)
{
$table->id();
$table->integer('site_id')->unsigned();
$table->string('domain_name',128);
$table->date('expire_at')->nullable();
$table->string('admin_url')->nullable();
$table->string('admin_user')->nullable();
$table->string('admin_pass')->nullable();
$table->integer('accounts')->nullable();
$table->integer('service_id')->unsigned();
$table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services');
$table->integer('tld_id')->unsigned();
$table->foreign('tld_id')->references('id')->on('tlds');
$table->unique(['id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('service_email');
Schema::dropIfExists('product_email');
Schema::dropIfExists('supplier_email');
}
};

View File

@ -0,0 +1,80 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('supplier_ssl',function (Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active')->default(false);
$table->string('product_id',16);
$table->string('product_desc',128)->nullable();
$table->float('base_cost');
$table->float('setup_cost')->nullable();
$table->integer('contract_term')->unsigned()->nullable();
$table->integer('supplier_detail_id')->unsigned();
$table->foreign(['supplier_detail_id','site_id'])->references(['id','site_id'])->on('supplier_details');
$table->unique(['id','site_id']);
});
Schema::create('product_ssl',function (Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active')->default(false);
$table->string('name',64);
$table->integer('contract_term')->unsigned()->nullable();
$table->integer('supplier_item_id')->unsigned();
$table->foreign(['supplier_item_id','site_id'])->references(['id','site_id'])->on('supplier_ssl');
$table->unique(['id','site_id']);
});
Schema::create('service_ssl', function(Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->integer('ssl_ca_id')->unsigned()->nullable();
$table->text('csr');
$table->text('pk')->nullable();
$table->text('cert')->nullable();
$table->integer('service_id')->unsigned();
$table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services');
$table->unique(['id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('service_ssl');
Schema::dropIfExists('product_ssl');
Schema::dropIfExists('supplier_ssl');
}
};

View File

@ -0,0 +1,111 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('supplier_phone',function (Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active')->default(false);
$table->string('product_id',16);
$table->string('product_desc',128)->nullable();
$table->float('base_cost');
$table->float('setup_cost')->nullable();
$table->integer('contract_term')->unsigned()->nullable();
$table->string('technology')->nullable();
$table->integer('supplier_detail_id')->unsigned();
$table->foreign(['supplier_detail_id','site_id'])->references(['id','site_id'])->on('supplier_details');
$table->unique(['id','site_id']);
});
Schema::create('product_phone',function (Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active')->default(false);
$table->string('name',64);
$table->integer('contract_term')->unsigned()->nullable();
$table->string('technology')->nullable();
$table->integer('supplier_item_id')->unsigned();
$table->foreign(['supplier_item_id','site_id'])->references(['id','site_id'])->on('supplier_phone');
$table->unique(['id','site_id']);
});
Schema::create('service_phone', function(Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->string('service_number',10)->nullable();
$table->string('service_address',128)->nullable();
$table->string('service_username',128)->nullable();
$table->string('service_password',32)->nullable();
$table->string('technology')->nullable();
$table->date('connect_at')->nullable();
$table->date('expire_at')->nullable();
$table->integer('service_id')->unsigned();
$table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services');
$table->unique(['id','site_id']);
});
Schema::create('cost_phone', function (Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active')->default(false);
$table->date('start_at')->nullable();
$table->date('end_at')->nullable();
$table->float('base')->nullable();
$table->float('excess')->nullable();
$table->string('reference')->nullable();
$table->text('notes')->nullable();
$table->integer('cost_id')->unsigned();
$table->foreign(['cost_id','site_id'])->references(['id','site_id'])->on('costs');
$table->integer('service_phone_id')->unsigned()->nullable();
$table->foreign(['service_phone_id','site_id'])->references(['id','site_id'])->on('service_phone');
$table->integer('supplier_phone_id')->unsigned()->nullable();
$table->foreign(['supplier_phone_id','site_id'])->references(['id','site_id'])->on('supplier_phone');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cost_phone');
Schema::dropIfExists('service_phone');
Schema::dropIfExists('product_phone');
Schema::dropIfExists('supplier_phone');
}
};

View File

@ -0,0 +1,144 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('supplier_broadband', function(Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active')->default(false);
$table->string('product_id',32);
$table->text('product_desc')->nullable();
$table->integer('metric')->nullable();
$table->string('speed',32)->nullable();
$table->string('technology')->nullable();
$table->float('base_cost');
$table->float('setup_cost')->nullable();
$table->integer('contract_term')->unsigned()->nullable();
$table->float('base_down_peak')->nullable();
$table->float('base_up_peak')->nullable();
$table->float('base_down_offpeak')->nullable();
$table->float('base_up_offpeak')->nullable();
$table->boolean('extra_charged')->default(false);
$table->boolean('extra_shaped')->default(false);
$table->float('extra_down_peak')->nullable();
$table->float('extra_up_peak')->nullable();
$table->float('extra_down_offpeak')->nullable();
$table->float('extra_up_offpeak')->nullable();
$table->time('offpeak_start')->nullable();
$table->time('offpeak_end')->nullable();
$table->integer('supplier_detail_id')->unsigned();
$table->foreign(['supplier_detail_id','site_id'])->references(['id','site_id'])->on('supplier_details');
$table->unique(['id','site_id']);
});
Schema::create('product_broadband', function(Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->integer('contract_term')->nullable();
$table->float('base_down_peak', 10, 0)->nullable();
$table->float('base_up_peak', 10, 0)->nullable();
$table->float('base_down_offpeak', 10, 0)->nullable();
$table->float('base_up_offpeak', 10, 0)->nullable();
$table->boolean('extra_charged')->nullable();
$table->string('extra_shaped', 8)->nullable();
$table->float('extra_down_peak', 10, 0)->nullable();
$table->float('extra_up_peak', 10, 0)->nullable();
$table->float('extra_down_offpeak', 10, 0)->nullable();
$table->float('extra_up_offpeak', 10, 0)->nullable();
$table->float('metric', 10, 0)->default(0);
$table->integer('supplier_item_id')->unsigned();
$table->foreign(['supplier_item_id','site_id'])->references(['id','site_id'])->on('supplier_broadband');
$table->index(['id','site_id']);
});
Schema::create('service_broadband', function(Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->string('service_number',16)->nullable();
$table->string('service_address',256)->nullable();
$table->string('service_username', 128)->nullable()->unique();
$table->string('service_password', 16)->nullable();
$table->boolean('service_stats_collect')->default(true);
$table->date('service_stats_at')->nullable();
$table->string('ipaddress', 45)->nullable();
$table->time('offpeak_start')->nullable();
$table->time('offpeak_end')->nullable();
$table->date('connect_at')->nullable();
$table->date('expire_at')->nullable();
$table->ipAddress('ip6address')->nullable();
$table->string('technology')->nullable();
$table->integer('provided_supplier_broadband_id')->unsigned()->nullable();
$table->foreign(['provided_supplier_broadband_id','site_id'])->references(['id','site_id'])->on('supplier_broadband');
$table->integer('service_id')->unsigned();
$table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services');
$table->unique(['id','site_id']);
});
Schema::create('cost_broadband', function (Blueprint $table)
{
$table->integer('id',TRUE,TRUE);
$table->integer('site_id')->unsigned();
$table->integer('cost_id')->unsigned();
$table->boolean('active');
$table->integer('service_broadband_id')->unsigned()->nullable();
$table->integer('supplier_broadband_id')->unsigned()->nullable();
$table->date('start_at')->nullable();
$table->date('end_at')->nullable();
$table->float('base')->nullable();
$table->float('excess')->nullable();
$table->string('reference')->nullable();
$table->text('notes')->nullable();
$table->foreign(['cost_id','site_id'])->references(['id','site_id'])->on('costs');
$table->foreign(['service_broadband_id','site_id'])->references(['id','site_id'])->on('service_broadband');
$table->foreign(['supplier_broadband_id','site_id'])->references(['id','site_id'])->on('supplier_broadband');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('cost_broadband');
Schema::drop('service_broadband');
Schema::drop('product_broadband');
Schema::drop('supplier_broadband');
}
};

View File

@ -0,0 +1,97 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('supplier_domain',function (Blueprint $table)
{
$table->id();
$table->timestamps();
$table->boolean('active')->default(false);
$table->string('product_id',16);
$table->string('product_desc',128)->nullable();
$table->float('base_cost');
$table->float('setup_cost')->nullable();
$table->integer('contract_term')->unsigned()->nullable();
$table->text('whois_url')->nullable();
$table->text('config')->nullable();
$table->integer('site_id')->unsigned();
$table->foreign(['site_id'])->references(['id'])->on('sites');
$table->integer('tld_id')->unsigned();
$table->foreign(['tld_id'])->references(['id'])->on('tlds');
$table->integer('supplier_detail_id')->unsigned();
$table->foreign(['supplier_detail_id','site_id'])->references(['id','site_id'])->on('supplier_details');
$table->unique(['id','site_id']);
});
Schema::create('product_domain',function (Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active')->default(false);
$table->string('name',64);
$table->integer('contract_term')->unsigned()->nullable();
$table->integer('supplier_item_id')->unsigned();
$table->foreign(['supplier_item_id','site_id'])->references(['id','site_id'])->on('supplier_domain');
$table->unique(['id','site_id']);
});
Schema::create('service_domain', function(Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->string('domain_name', 256);
$table->date('expire_at')->nullable();
$table->string('registrar_account', 32)->nullable();
$table->string('registrar_username', 128)->nullable();
$table->string('registrar_auth_password', 128)->nullable();
$table->string('registrar_ns', 1024)->nullable();
$table->integer('domain_registrar_id')->unsigned()->nullable();
$table->foreign(['domain_registrar_id','site_id'])->references(['id','site_id'])->on('domain_registrars');
$table->integer('service_id')->unsigned();
$table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services');
$table->integer('tld_id')->unsigned();
$table->foreign(['tld_id'])->references(['id'])->on('tlds');
$table->unique(['id','site_id']);
$table->unique(['domain_name','tld_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('service_domain');
Schema::drop('product_domain');
Schema::drop('supplier_domain');
}
};

View File

@ -0,0 +1,91 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('supplier_host',function (Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active')->default(false);
$table->string('product_id',16);
$table->string('product_desc',128)->nullable();
$table->float('base_cost');
$table->float('setup_cost')->nullable();
$table->integer('contract_term')->unsigned()->nullable();
$table->integer('supplier_detail_id')->unsigned();
$table->foreign(['supplier_detail_id','site_id'])->references(['id','site_id'])->on('supplier_details');
$table->unique(['id','site_id']);
});
Schema::create('product_host',function (Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active')->default(false);
$table->string('name',64);
$table->integer('contract_term')->unsigned()->nullable();
$table->integer('supplier_item_id')->unsigned();
$table->foreign(['supplier_item_id','site_id'])->references(['id','site_id'])->on('supplier_host');
$table->unique(['id','site_id']);
});
Schema::create('service_host', function(Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->string('domain_name', 128)->nullable();
$table->string('host_type',16)->nullable();
$table->string('host_username',45)->nullable();
$table->string('host_password',45)->nullable();
$table->string('ftp_username',16)->nullable();
$table->string('ftp_password',16)->nullable();
$table->binary('server_data',65535)->nullable();
$table->date('expire_at')->nullable();
$table->integer('service_id')->unsigned();
$table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services');
$table->integer('supplier_host_server_id')->unsigned()->nullable();
$table->foreign(['supplier_host_server_id','site_id'])->references(['id','site_id'])->on('supplier_host_servers');
$table->integer('tld_id')->unsigned();
$table->foreign(['tld_id'])->references(['id'])->on('tlds');
$table->unique(['id','site_id']);
$table->unique(['supplier_host_server_id','ftp_username']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('service_host');
Schema::drop('product_host');
Schema::drop('supplier_host');
}
};

View File

@ -0,0 +1,99 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('supplier_generic',function (Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active')->default(false);
$table->string('product_id',16)->nullable();
$table->string('product_desc',128)->nullable();
$table->float('base_cost');
$table->float('setup_cost')->nullable();
$table->integer('contract_term')->unsigned()->nullable();
$table->integer('supplier_detail_id')->unsigned();
$table->foreign(['supplier_detail_id','site_id'])->references(['id','site_id'])->on('supplier_details');
$table->unique(['id','site_id']);
});
Schema::create('product_generic',function (Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active')->default(false);
$table->string('name',64);
$table->integer('contract_term')->unsigned()->nullable();
$table->integer('supplier_item_id')->unsigned();
$table->foreign(['supplier_item_id','site_id'])->references(['id','site_id'])->on('supplier_generic');
$table->unique(['id','site_id']);
});
Schema::create('service_generic', function (Blueprint $table)
{
$table->id();
$table->integer('site_id')->unsigned();
$table->integer('service_id')->unsigned();
$table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services');
$table->integer('product_id')->unsigned()->nullable();
$table->foreign(['product_id','site_id'])->references(['id','site_id'])->on('products');
$table->unique(['id','site_id']);
$table->unique(['site_id','service_id']);
});
Schema::create('cost_generic', function (Blueprint $table)
{
$table->integer('id',TRUE,TRUE);
$table->integer('site_id')->unsigned();
$table->integer('cost_id')->unsigned();
$table->boolean('active');
$table->integer('service_generic_id')->unsigned()->nullable();
$table->integer('supplier_generic_id')->unsigned()->nullable();
$table->date('start_at')->nullable();
$table->date('end_at')->nullable();
$table->float('base')->nullable();
$table->float('excess')->nullable();
$table->string('reference')->nullable();
$table->text('notes')->nullable();
$table->foreign(['cost_id','site_id'])->references(['id','site_id'])->on('costs');
$table->foreign(['service_generic_id','site_id'])->references(['id','site_id'])->on('service_generic');
$table->foreign(['supplier_generic_id','site_id'])->references(['id','site_id'])->on('supplier_generic');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cost_generic');
Schema::dropIfExists('service_generic');
Schema::dropIfExists('product_generic');
Schema::dropIfExists('supplier_generic');
}
};

View File

@ -0,0 +1,52 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('usage_broadband', function(Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->date('date');
$table->time('time')->nullable();
$table->string('service',128)->nullable();
$table->integer('up_peak')->nullable();
$table->integer('up_offpeak')->nullable();
$table->integer('down_peak')->nullable();
$table->integer('down_offpeak')->nullable();
$table->integer('peer')->nullable();
$table->integer('internal')->nullable();
$table->integer('service_item_id')->nullable();
$table->foreign(['service_item_id','site_id'])->references(['id','site_id'])->on('service_broadband');
$table->integer('supplier_id'); // @todo To remove?
$table->foreign(['supplier_id'])->references(['id'])->on('suppliers');
$table->unique(['service_item_id','site_id','date','time']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('usage_broadband');
}
};

View File

@ -0,0 +1,49 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('checkouts', function(Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active')->default(false);
$table->string('name',32);
$table->string('description')->nullable();
$table->string('plugin', 32)->nullable();
$table->text('plugin_data')->nullable();
$table->string('graphic_url', 128)->nullable();
$table->float('amount_min', 10, 0)->default(0);
$table->float('amount_max', 10, 0)->nullable();
$table->float('fee_fixed', 10, 0)->nullable();
$table->float('fee_variable', 10, 0)->nullable();
$table->boolean('fee_passon')->default(false);
$table->foreign(['site_id'])->references(['id'])->on('sites');
$table->unique(['id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('checkouts');
}
};

View File

@ -0,0 +1,48 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('invoices', function(Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active')->default(false);
$table->date('due_at');
$table->boolean('process_status')->nullable();
$table->boolean('billing_status')->nullable();
$table->boolean('print_status')->default(false);
$table->integer('account_billing_id')->nullable();
$table->float('discount_amt',10,0)->nullable();
$table->binary('reminders', 65535)->nullable();
$table->integer('account_id')->unsigned();
$table->foreign(['account_id','site_id'])->references(['id','site_id'])->on('accounts');
$table->unique(['id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('invoices');
}
};

View File

@ -0,0 +1,57 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('invoice_items', function(Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active')->default(false);
$table->date('start_at')->nullable();
$table->date('stop_at')->nullable();
$table->integer('module_id')->nullable();
$table->bigInteger('module_ref')->nullable();
$table->float('quantity', 10, 0)->nullable();
$table->integer('item_type')->nullable();
$table->string('product_name', 128)->nullable();
$table->float('discount_amt', 10, 0)->nullable();
$table->float('price_base', 10, 0)->nullable();
$table->integer('recur_schedule')->nullable();
$table->integer('invoice_id')->unsigned();
$table->foreign(['invoice_id','site_id'])->references(['id','site_id'])->on('invoices');
$table->integer('product_id')->unsigned()->nullable();
$table->foreign(['product_id','site_id'])->references(['id','site_id'])->on('products');
$table->integer('service_id')->unsigned()->nullable();
$table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services');
$table->unique(['id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('invoice_items');
}
};

View File

@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('invoice_item_taxes', function(Blueprint $table)
{
$table->id();
$table->integer('site_id')->unsigned();
$table->boolean('active')->default(false);
$table->float('amount',10,0);
$table->integer('invoice_item_id')->unsigned();
$table->foreign(['invoice_item_id','site_id'])->references(['id','site_id'])->on('invoice_items');
$table->integer('tax_id')->unsigned();
$table->foreign('tax_id')->references('id')->on('taxes');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('invoice_item_taxes');
}
};

View File

@ -0,0 +1,50 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('provider_tokens', function (Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->bigInteger('realm_id')->unsigned();
$table->text('access_token');
$table->datetime('access_token_expires_at');
$table->string('refresh_token');
$table->datetime('refresh_token_expires_at');
$table->integer('user_id')->unsigned();
$table->foreign(['user_id','site_id'])->references(['id','site_id'])->on('users');
$table->integer('provider_oauth_id')->unsigned();
$table->foreign(['provider_oauth_id','site_id'])->references(['id','site_id'])->on('provider_oauth');
$table->unique(['id','site_id']);
$table->unique(['provider_oauth_id','user_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('provider_tokens');
}
};

View File

@ -0,0 +1,47 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('user_oauth', function(Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->string('userid',128);
$table->binary('oauth_data', 65535)->nullable();
$table->integer('user_id')->unsigned()->nullable();
$table->integer('provider_oauth_id')->unsigned();
$table->foreign(['provider_oauth_id','site_id'])->references(['id','site_id'])->on('provider_oauth');
$table->index(['user_id','site_id']);
$table->foreign(['user_id','site_id'])->references(['id','site_id'])->on('users');
$table->unique(['id','site_id']);
$table->unique(['site_id','user_id','provider_oauth_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('user_oauth');
}
};

View File

@ -0,0 +1,55 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('payments', function(Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active')->default(false);
$table->string('checkout_data')->nullable();
$table->float('total_amt', 10, 0);
$table->float('fees_amt', 10, 0)->nullable();
$table->boolean('pending_status')->nullable();
$table->text('notes', 65535)->nullable();
$table->string('ip', 128)->nullable();
$table->string('pending')->nullable();
$table->date('paid_at');
$table->integer('account_id')->unsigned();
$table->foreign(['account_id','site_id'])->references(['id','site_id'])->on('accounts');
$table->integer('checkout_id')->unsigned();
$table->foreign(['checkout_id','site_id'])->references(['id','site_id'])->on('checkouts');
$table->integer('source_id')->nullable();
$table->foreign(['source_id','site_id'])->references(['id','site_id'])->on('users');
$table->unique(['id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('payments');
}
};

View File

@ -0,0 +1,45 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('payment_items', function(Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active')->default(false);
$table->float('amount',10,0);
$table->integer('invoice_id')->unsigned()->nullable();
$table->foreign(['invoice_id','site_id'])->references(['id','site_id'])->on('invoices');
$table->integer('payment_id')->unsigned();
$table->foreign(['payment_id','site_id'])->references(['id','site_id'])->on('payments');
$table->unique(['id','site_id']);
$table->unique(['site_id','invoice_id','payment_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('payment_items');
}
};

View File

@ -13,7 +13,23 @@ return new class extends Migration
*/
public function up()
{
Schema::create('invoice__provider', function (Blueprint $table) {
Schema::create('account__provider', function (Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->string('ref');
$table->integer('synctoken');
$table->integer('account_id')->unsigned();
$table->foreign(['account_id','site_id'])->references(['id','site_id'])->on('accounts');
$table->integer('provider_oauth_id')->unsigned();
$table->foreign(['provider_oauth_id','site_id'])->references(['id','site_id'])->on('provider_oauth');
});
Schema::create('invoice__provider', function (Blueprint $table)
{
$table->timestamps();
$table->integer('invoice_id')->unsigned();
$table->integer('provider_oauth_id')->unsigned();
@ -25,7 +41,8 @@ return new class extends Migration
$table->foreign(['provider_oauth_id','site_id'])->references(['id','site_id'])->on('provider_oauth');
});
Schema::create('product__provider', function (Blueprint $table) {
Schema::create('product__provider', function (Blueprint $table)
{
$table->integer('product_id')->unsigned();
$table->integer('provider_oauth_id')->unsigned();
$table->integer('site_id')->unsigned();
@ -35,7 +52,8 @@ return new class extends Migration
$table->foreign(['provider_oauth_id','site_id'])->references(['id','site_id'])->on('provider_oauth');
});
Schema::create('tax__provider', function (Blueprint $table) {
Schema::create('tax__provider', function (Blueprint $table)
{
$table->timestamps();
$table->integer('tax_id')->unsigned();
$table->integer('provider_oauth_id')->unsigned();
@ -47,8 +65,17 @@ return new class extends Migration
$table->foreign(['provider_oauth_id','site_id'])->references(['id','site_id'])->on('provider_oauth');
});
Schema::table('products', function (Blueprint $table) {
$table->dropColumn('accounting');
Schema::create('payment__provider', function (Blueprint $table)
{
$table->timestamps();
$table->integer('payment_id')->unsigned();
$table->integer('provider_oauth_id')->unsigned();
$table->integer('site_id')->unsigned();
$table->string('ref');
$table->integer('synctoken');
$table->foreign(['payment_id','site_id'])->references(['id','site_id'])->on('payments');
$table->foreign(['provider_oauth_id','site_id'])->references(['id','site_id'])->on('provider_oauth');
});
}
@ -59,12 +86,10 @@ return new class extends Migration
*/
public function down()
{
Schema::dropIfExists('payment__provider');
Schema::dropIfExists('tax__provider');
Schema::dropIfExists('product__provider');
Schema::dropIfExists('invoice__provider');
Schema::table('products', function (Blueprint $table) {
$table->string('accounting');
});
Schema::dropIfExists('account__provider');
}
};

View File

@ -1,10 +1,10 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
return new class extends Migration
class CreatePasswordResetsTable extends Migration
{
/**
* Run the migrations.
@ -13,7 +13,11 @@ return new class extends Migration
*/
public function up()
{
DB::statement('ALTER TABLE service_domain MODIFY domain_registrar_id INT UNSIGNED DEFAULT NULL');
Schema::create('password_resets', function (Blueprint $table) {
$table->string('email')->index();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
}
/**
@ -23,6 +27,6 @@ return new class extends Migration
*/
public function down()
{
DB::statement('ALTER TABLE service_domain MODIFY domain_registrar_id INT UNSIGNED NOT NULL');
Schema::dropIfExists('password_resets');
}
}
};

View File

@ -0,0 +1,43 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbAccountBillingTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_account_billing', function(Blueprint $table)
{
$table->integer('id');
$table->integer('site_id');
$table->bigInteger('account_id')->nullable();
$table->integer('checkout_id');
$table->bigInteger('service_id')->nullable();
$table->binary('checkout_data', 65535)->nullable();
$table->float('checkout_amount', 10, 0)->nullable();
$table->string('notes', 128)->nullable();
$table->primary(['id','site_id','checkout_id']);
$table->unique(['site_id','service_id']);
$table->index(['account_id','site_id']);
$table->index(['service_id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_account_billing');
}
}

View File

@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbAccountLogTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_account_log', function(Blueprint $table)
{
$table->bigInteger('id')->default(0);
$table->integer('site_id')->default(0);
$table->bigInteger('date_orig')->nullable();
$table->bigInteger('account_id')->default(0);
$table->string('ip', 32)->nullable();
$table->string('details', 256)->nullable();
$table->primary(['id','site_id','account_id']);
$table->index(['account_id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_account_log');
}
}

View File

@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbAccountMemoTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_account_memo', function(Blueprint $table)
{
$table->bigInteger('id')->nullable();
$table->integer('site_id')->nullable();
$table->bigInteger('date_orig')->nullable();
$table->bigInteger('staff_id')->nullable();
$table->bigInteger('account_id')->nullable()->index('account');
$table->string('type', 32)->nullable();
$table->string('memo')->nullable()->index('memo');
$table->string('misc', 32)->nullable();
$table->unique(['site_id','id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_account_memo');
}
}

View File

@ -0,0 +1,50 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbAffiliateTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_affiliate', function(Blueprint $table)
{
$table->bigInteger('id')->default(0);
$table->integer('site_id')->default(0);
$table->bigInteger('date_orig')->nullable();
$table->bigInteger('date_last')->nullable();
$table->boolean('active')->nullable();
$table->bigInteger('account_id')->default(0);
$table->text('avail_campaign_id')->nullable();
$table->string('affiliate_plugin', 32)->nullable();
$table->string('parent_affiliate_id', 16)->nullable();
$table->integer('max_tiers')->nullable();
$table->float('commission_minimum', 10, 0)->nullable();
$table->boolean('new_commission_type')->nullable();
$table->text('new_commission_rate')->nullable();
$table->boolean('recurr_commission_type')->nullable();
$table->text('recurr_commission_rate')->nullable();
$table->integer('recurr_max_commission_periods')->nullable();
$table->text('plugin_data')->nullable();
$table->primary(['id','site_id','account_id']);
$table->index(['account_id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_affiliate');
}
}

View File

@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbAssetPoolTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_asset_pool', function(Blueprint $table)
{
$table->integer('id')->nullable();
$table->integer('site_id')->nullable();
$table->string('name', 32)->nullable();
$table->unique(['site_id','id']);
$table->index(['id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_asset_pool');
}
}

View File

@ -0,0 +1,42 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbAssetTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_asset', function(Blueprint $table)
{
$table->bigInteger('id')->nullable();
$table->integer('site_id')->nullable();
$table->bigInteger('date_orig')->nullable();
$table->bigInteger('date_last')->nullable();
$table->boolean('active')->nullable();
$table->bigInteger('service_id')->nullable()->index('service');
$table->integer('pool_id')->nullable()->index('asso');
$table->string('asset', 128)->nullable()->index('asset');
$table->string('misc')->nullable();
$table->unique(['site_id','id']);
$table->index(['id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_asset');
}
}

View File

@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbCartTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_cart', function(Blueprint $table)
{
$table->integer('id')->default(0);
$table->integer('site_id')->default(0);
$table->bigInteger('date_orig')->nullable();
$table->string('session_id', 32)->default('');
$table->integer('quantity')->nullable();
$table->integer('module_id')->default(0);
$table->integer('module_item')->default(0);
$table->text('module_data', 65535)->nullable();
$table->primary(['id','site_id']);
$table->index(['module_id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_cart');
}
}

View File

@ -0,0 +1,42 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbCheckoutNotifyTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_checkout_notify', function(Blueprint $table)
{
$table->bigInteger('id');
$table->integer('site_id');
$table->bigInteger('date_orig')->nullable();
$table->bigInteger('date_last')->nullable();
$table->integer('checkout_id');
$table->boolean('active')->nullable();
$table->binary('data', 65535);
$table->boolean('processed')->nullable();
$table->text('result', 65535)->nullable();
$table->primary(['id','site_id','checkout_id']);
$table->index(['checkout_id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_checkout_notify');
}
}

View File

@ -0,0 +1,56 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbDiscountTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_discount', function(Blueprint $table)
{
$table->bigInteger('id')->nullable();
$table->integer('site_id')->nullable();
$table->bigInteger('date_orig')->nullable();
$table->boolean('active')->nullable()->index();
$table->bigInteger('date_start')->nullable()->index();
$table->bigInteger('date_expire')->nullable()->index();
$table->string('name', 64)->nullable();
$table->text('notes')->nullable();
$table->integer('max_usage_account')->nullable();
$table->integer('max_usage_global')->nullable();
$table->bigInteger('avail_account_id')->nullable();
$table->text('avail_product_id')->nullable();
$table->text('avail_group_id')->nullable();
$table->text('avail_tld_id')->nullable();
$table->boolean('new_status')->nullable();
$table->boolean('new_type')->nullable();
$table->float('new_rate', 10, 0)->nullable();
$table->float('new_max_discount', 10, 0)->nullable();
$table->float('new_min_cost', 10, 0)->nullable();
$table->boolean('recurr_status')->nullable();
$table->boolean('recurr_type')->nullable();
$table->float('recurr_rate', 10, 0)->nullable();
$table->float('recurr_max_discount', 10, 0)->nullable();
$table->float('recurr_min_cost', 10, 0)->nullable();
$table->unique(['site_id','id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_discount');
}
}

View File

@ -0,0 +1,49 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbEmailLogTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_email_log', function(Blueprint $table)
{
$table->bigInteger('id')->default(0);
$table->integer('site_id')->default(0);
$table->bigInteger('date_orig')->nullable();
$table->bigInteger('account_id')->default(0);
$table->bigInteger('email_template_translate_id')->nullable();
$table->string('email', 128)->nullable();
$table->string('subject', 128)->nullable();
$table->text('message')->nullable();
$table->boolean('html')->nullable();
$table->boolean('urgent')->nullable();
$table->boolean('userread')->nullable();
$table->binary('data', 65535)->nullable();
$table->integer('module_id')->nullable();
$table->string('module_data', 128)->nullable();
$table->primary(['id','site_id','account_id']);
$table->index(['email_template_translate_id','site_id']);
$table->index(['account_id','site_id']);
$table->index(['module_id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_email_log');
}
}

View File

@ -0,0 +1,52 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbEmailSetupTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_email_setup', function(Blueprint $table)
{
$table->integer('id')->default(0);
$table->integer('site_id')->default(0);
$table->bigInteger('account_id')->default(0);
$table->string('name', 128)->nullable();
$table->text('notes')->nullable();
$table->boolean('type')->nullable();
$table->string('from_name', 128)->nullable();
$table->string('from_email', 128)->nullable();
$table->text('cc_list')->nullable();
$table->text('bcc_list')->nullable();
$table->string('server', 128)->nullable();
$table->string('username', 128)->nullable();
$table->string('password', 128)->nullable();
$table->string('piping', 4)->nullable();
$table->string('piping_host', 128)->nullable();
$table->string('piping_username', 128)->nullable();
$table->string('piping_password', 128)->nullable();
$table->string('piping_action', 4)->nullable();
$table->boolean('queue')->nullable();
$table->primary(['id','site_id','account_id']);
$table->index(['account_id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_email_setup');
}
}

View File

@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbEmailTemplateTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_email_template', function(Blueprint $table)
{
$table->bigInteger('id')->default(0);
$table->integer('site_id')->default(0);
$table->boolean('active')->nullable();
$table->integer('email_setup_id')->default(0);
$table->string('name', 128)->nullable();
$table->string('description', 32)->nullable();
$table->text('notes')->nullable();
$table->primary(['id','site_id','email_setup_id']);
$table->index(['email_setup_id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_email_template');
}
}

View File

@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbEmailTemplateTranslateTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_email_template_translate', function(Blueprint $table)
{
$table->bigInteger('id')->default(0);
$table->integer('site_id')->default(0);
$table->bigInteger('email_template_id')->default(0);
$table->integer('language_id')->default(0)->index();
$table->string('subject');
$table->text('message_text');
$table->text('message_html')->nullable();
$table->primary(['id','site_id','email_template_id','language_id']);
$table->index(['email_template_id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_email_template_translate');
}
}

View File

@ -0,0 +1,44 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbExportDatamapTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_export_datamap', function(Blueprint $table)
{
$table->bigInteger('id')->default(0);
$table->integer('site_id')->default(0);
$table->bigInteger('export_module_id')->default(0);
$table->bigInteger('date_orig')->nullable();
$table->bigInteger('date_last')->nullable();
$table->boolean('active')->nullable();
$table->bigInteger('item_id')->nullable();
$table->integer('module_id');
$table->binary('map_data', 65535)->nullable();
$table->primary(['id','site_id','export_module_id','module_id']);
$table->unique(['item_id','export_module_id','site_id']);
$table->index(['export_module_id','site_id']);
$table->index(['module_id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_export_datamap');
}
}

View File

@ -0,0 +1,42 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbExportItemTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_export_item', function(Blueprint $table)
{
$table->bigInteger('id')->default(0);
$table->integer('site_id')->default(0);
$table->bigInteger('export_module_id')->default(0);
$table->bigInteger('date_orig')->nullable();
$table->bigInteger('date_last')->nullable();
$table->bigInteger('item_id')->default(0);
$table->string('reference', 64)->nullable();
$table->string('crc', 128)->nullable();
$table->primary(['id','site_id','export_module_id']);
$table->unique(['site_id','export_module_id','item_id']);
$table->index(['export_module_id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_export_item');
}
}

View File

@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbExportModuleTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_export_module', function(Blueprint $table)
{
$table->bigInteger('id')->default(0);
$table->integer('site_id')->default(0);
$table->bigInteger('export_id')->default(0);
$table->integer('module_id')->default(0);
$table->binary('display', 65535)->nullable();
$table->primary(['id','site_id','export_id','module_id']);
$table->index(['export_id','site_id']);
$table->index(['module_id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_export_module');
}
}

View File

@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbExportTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_export', function(Blueprint $table)
{
$table->bigInteger('id')->default(0);
$table->integer('site_id')->default(0)->index();
$table->string('name', 128)->default('');
$table->string('plugin', 128)->default('');
$table->boolean('active')->nullable();
$table->string('url', 128)->nullable();
$table->primary(['id','site_id']);
$table->unique(['site_id','name']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_export');
}
}

View File

@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbGroupMethodTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_group_method', function(Blueprint $table)
{
$table->integer('id')->default(0);
$table->integer('site_id')->default(0);
$table->integer('method_id')->default(0);
$table->integer('group_id')->default(0);
$table->primary(['id','site_id','method_id','group_id']);
$table->unique(['id','site_id']);
$table->index(['method_id','site_id']);
$table->index(['group_id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_group_method');
}
}

View File

@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbHostServerAffiliateTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_host_server_affiliate', function(Blueprint $table)
{
$table->bigInteger('id');
$table->integer('site_id');
$table->bigInteger('affiliate_id');
$table->integer('host_server_id');
$table->string('host_username', 45)->nullable();
$table->string('host_password', 45)->nullable();
$table->primary(['id','site_id','affiliate_id','host_server_id']);
$table->index(['affiliate_id','site_id']);
$table->index(['host_server_id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_host_server_affiliate');
}
}

View File

@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbImportTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_import', function(Blueprint $table)
{
$table->bigInteger('id')->nullable();
$table->integer('site_id')->nullable();
$table->bigInteger('date_orig')->nullable();
$table->string('plugin', 32)->nullable();
$table->string('action', 32)->nullable();
$table->string('remote_table', 32)->nullable();
$table->string('ab_table', 32)->nullable();
$table->bigInteger('remote_id')->nullable();
$table->bigInteger('ab_id')->nullable();
$table->unique(['site_id','id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_import');
}
}

View File

@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbInvoiceItemDiscountTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_invoice_item_discount', function(Blueprint $table)
{
$table->integer('id')->nullable();
$table->integer('site_id')->nullable();
$table->bigInteger('date_orig')->nullable()->index();
$table->bigInteger('invoice_id')->nullable();
$table->bigInteger('account_id')->nullable()->index();
$table->bigInteger('invoice_item_id')->nullable();
$table->string('discount', 64)->nullable()->index();
$table->float('amount', 10, 0)->nullable();
$table->unique(['site_id','id'], );
$table->index(['invoice_id','invoice_item_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_invoice_item_discount');
}
}

View File

@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbInvoiceMemoTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_invoice_memo', function(Blueprint $table)
{
$table->bigInteger('id')->default(0);
$table->integer('site_id')->default(0);
$table->bigInteger('date_orig')->nullable();
$table->bigInteger('invoice_id')->default(0);
$table->bigInteger('account_id')->nullable();
$table->string('type', 32)->nullable();
$table->binary('memo', 65535)->nullable();
$table->primary(['id','site_id','invoice_id']);
$table->index(['invoice_id','site_id']);
$table->index(['account_id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_invoice_memo');
}
}

View File

@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbLogErrorTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_log_error', function(Blueprint $table)
{
$table->bigInteger('id')->nullable();
$table->integer('site_id')->nullable();
$table->bigInteger('date_orig')->nullable();
$table->bigInteger('account_id')->nullable();
$table->string('module', 64)->nullable();
$table->string('method', 64)->nullable();
$table->text('message')->nullable();
$table->unique(['site_id','id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_log_error');
}
}

View File

@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbModuleMethodTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_module_method', function(Blueprint $table)
{
$table->integer('id')->default(0);
$table->integer('site_id')->default(0);
$table->integer('module_id')->default(0);
$table->string('name', 64)->nullable()->default('');
$table->string('notes', 128)->nullable();
$table->string('menu_display', 32)->nullable();
$table->primary(['id','site_id','module_id']);
$table->unique(['id','site_id']);
$table->unique(['site_id','module_id','name']);
$table->index(['module_id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_module_method');
}
}

View File

@ -0,0 +1,43 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbModuleMethodTokenTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_module_method_token', function(Blueprint $table)
{
$table->integer('id')->default(0);
$table->integer('site_id')->default(0);
$table->integer('method_id')->default(0);
$table->bigInteger('account_id')->default(0);
$table->string('token', 36)->default('');
$table->bigInteger('date_orig')->default(0);
$table->bigInteger('date_last')->nullable();
$table->bigInteger('date_expire')->nullable();
$table->string('uses', 45)->nullable();
$table->primary(['id','site_id','method_id','account_id']);
$table->index(['method_id','site_id']);
$table->index(['account_id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_module_method_token');
}
}

View File

@ -0,0 +1,42 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbModuleTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_module', function(Blueprint $table)
{
$table->integer('id')->default(0);
$table->integer('site_id')->default(0)->index();
$table->string('name', 128)->default('');
$table->bigInteger('date_orig')->nullable();
$table->boolean('active')->nullable();
$table->integer('parent_id')->nullable();
$table->text('notes')->nullable();
$table->boolean('external')->nullable();
$table->primary(['id','site_id']);
$table->unique(['site_id','name']);
$table->index(['parent_id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_module');
}
}

View File

@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbPivotProductCatTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_pivot_product_cat', function(Blueprint $table)
{
$table->bigInteger('id', false);
$table->integer('site_id');
$table->bigInteger('product_id')->nullable();
$table->integer('product_cat_id')->nullable();
$table->primary(['id','site_id']);
$table->unique(['site_id','product_id','product_cat_id']);
$table->index(['product_cat_id','site_id']);
$table->index(['product_id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_pivot_product_cat');
}
}

View File

@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbProductCatTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_product_cat', function(Blueprint $table)
{
$table->integer('id')->default(0);
$table->integer('site_id')->default(0)->index();
$table->integer('parent_id')->nullable()->index();
$table->binary('group_avail', 65535)->nullable();
$table->binary('notes', 65535)->nullable();
$table->boolean('active')->nullable();
$table->string('template', 128)->nullable();
$table->integer('position')->nullable();
$table->integer('recur_schedule')->default(0);
$table->primary(['id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_product_cat');
}
}

View File

@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbProductCatTranslateTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_product_cat_translate', function(Blueprint $table)
{
$table->integer('id')->default(0);
$table->integer('site_id')->default(0);
$table->integer('product_cat_id')->default(0);
$table->integer('language_id')->default(0)->index();
$table->string('name', 128)->nullable();
$table->binary('description', 65535)->nullable();
$table->primary(['id','site_id','product_cat_id','language_id']);
$table->unique(['site_id','product_cat_id','language_id']);
$table->index(['product_cat_id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_product_cat_translate');
}
}

View File

@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbRecordIdTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_record_id', function(Blueprint $table)
{
$table->integer('site_id')->default(0)->index();
$table->integer('module_id')->default(0);
$table->integer('id')->default(0);
$table->primary(['site_id','module_id']);
$table->index(['module_id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_record_id');
}
}

View File

@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbServiceMemoTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_service_memo', function(Blueprint $table)
{
$table->bigInteger('id')->default(0);
$table->integer('site_id')->default(0);
$table->bigInteger('date_orig')->nullable();
$table->bigInteger('service_id')->default(0);
$table->bigInteger('account_id')->nullable();
$table->string('type', 32)->nullable();
$table->binary('memo', 65535)->nullable();
$table->primary(['id','site_id','service_id']);
$table->index(['service_id','site_id']);
$table->index(['account_id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_service_memo');
}
}

View File

@ -0,0 +1,50 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbSetupInvoiceTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_setup_invoice', function(Blueprint $table)
{
$table->integer('id')->nullable();
$table->integer('site_id')->nullable();
$table->boolean('bill_to_company')->nullable();
$table->string('invoice_currency', 8)->nullable();
$table->integer('invoice_decimals')->nullable();
$table->integer('items_summary_max')->nullable();
$table->text('news', 65535)->nullable();
$table->string('page_type', 8)->nullable();
$table->integer('invoice_delivery')->nullable();
$table->boolean('invoice_show_itemized')->nullable();
$table->boolean('invoice_show_service_dates')->nullable();
$table->integer('invoice_grace')->nullable();
$table->integer('invoice_advance_gen')->nullable();
$table->integer('invoice_terms')->nullable();
$table->string('invoice_pdf_plugin', 16)->nullable();
$table->string('contact_us_url', 64)->nullable();
$table->string('contact_us_phone', 64)->nullable();
$table->integer('advance_notice')->nullable();
$table->unique(['site_id','id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_setup_invoice');
}
}

View File

@ -0,0 +1,42 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbSslCaTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_ssl_ca', function(Blueprint $table)
{
$table->bigInteger('id');
$table->integer('site_id');
$table->bigInteger('account_id')->default(0);
$table->bigInteger('date_orig')->nullable();
$table->boolean('active')->nullable();
$table->text('sign_pk', 65535);
$table->text('sign_cert', 65535);
$table->bigInteger('parent_ssl_ca_id')->nullable();
$table->primary(['id','site_id','account_id']);
$table->index(['parent_ssl_ca_id','site_id']);
$table->index(['account_id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_ssl_ca');
}
}

View File

@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbSslTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_ssl', function(Blueprint $table)
{
$table->bigInteger('id');
$table->integer('site_id')->index();
$table->string('extensions', 64);
$table->primary(['id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_ssl');
}
}

View File

@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbStaticPageCategoryTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_static_page_category', function(Blueprint $table)
{
$table->integer('id')->nullable();
$table->integer('site_id')->nullable();
$table->bigInteger('date_orig')->nullable();
$table->string('group_avail')->nullable();
$table->string('name', 128)->nullable()->index();
$table->text('description')->nullable();
$table->boolean('active')->nullable()->index();
$table->integer('sort_order')->nullable();
$table->unique(['site_id','id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_static_page_category');
}
}

View File

@ -0,0 +1,43 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbStaticPageTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_static_page', function(Blueprint $table)
{
$table->integer('id')->nullable();
$table->integer('site_id')->nullable();
$table->bigInteger('date_orig')->nullable();
$table->bigInteger('date_last')->nullable();
$table->integer('static_page_category_id')->nullable()->index();
$table->bigInteger('date_start')->nullable()->index();
$table->bigInteger('date_expire')->nullable()->index();
$table->integer('sort_order')->nullable();
$table->boolean('active')->nullable();
$table->string('name', 128)->nullable()->index();
$table->text('description')->nullable();
$table->unique(['site_id','id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_static_page');
}
}

View File

@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbStaticPageTranslateTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_static_page_translate', function(Blueprint $table)
{
$table->integer('id')->nullable();
$table->integer('site_id')->nullable();
$table->bigInteger('date_orig')->nullable();
$table->bigInteger('date_last')->nullable();
$table->integer('static_page_id')->nullable();
$table->string('language_id', 16)->nullable();
$table->text('body_intro')->nullable();
$table->text('body_full')->nullable();
$table->string('title', 128)->nullable();
$table->unique(['site_id','id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_static_page_translate');
}
}

View File

@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbTaskLogTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_task_log', function(Blueprint $table)
{
$table->bigInteger('id')->default(0);
$table->integer('site_id')->default(0);
$table->bigInteger('date_orig')->nullable();
$table->bigInteger('task_id')->default(0);
$table->integer('result')->nullable();
$table->binary('message', 65535)->nullable();
$table->primary(['id','site_id','task_id']);
$table->index(['task_id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_task_log');
}
}

View File

@ -0,0 +1,50 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateAbTaskTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ab_task', function(Blueprint $table)
{
$table->bigInteger('id')->default(0);
$table->integer('site_id')->default(0)->index();
$table->bigInteger('date_orig')->nullable();
$table->bigInteger('date_last')->nullable();
$table->bigInteger('date_run')->nullable();
$table->integer('active')->nullable();
$table->string('name', 32)->nullable();
$table->string('description')->nullable();
$table->boolean('log')->nullable();
$table->integer('type')->nullable();
$table->string('command', 128)->nullable();
$table->string('int_min', 32)->nullable();
$table->string('int_hour', 32)->nullable();
$table->string('int_month', 32)->nullable();
$table->string('int_month_day', 32)->nullable();
$table->string('int_week_day', 32)->nullable();
$table->boolean('running')->nullable();
$table->string('running_host', 4)->nullable();
$table->primary(['id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ab_task');
}
}

View File

@ -0,0 +1,36 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateJobsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('jobs', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedTinyInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('jobs');
}
}

View File

@ -0,0 +1,35 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateFailedJobsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('failed_jobs', function (Blueprint $table) {
$table->bigIncrements('id');
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('failed_jobs');
}
}

View File

@ -1,35 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class ReworkDomains extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
DB::statement('ALTER TABLE ab_service__domain MODIFY COLUMN id INT auto_increment');
DB::statement('ALTER TABLE ab_service__domain RENAME TO service_domains');
Schema::table('service_domains', function (Blueprint $table) {
$table->renameColumn('registrar_type','registrar_account');
$table->unique(['domain_name','domain_tld_id']);
$table->dropColumn(['registrar_password','registrar_pending_transfer']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
abort(500,'cant go back');
}
}

View File

@ -1,56 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class ReworkPayments extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('ab_payment_item', function (Blueprint $table) {
$table->dropUnique('UNIQUE');
$table->dropForeign('fk_pi_pay');
$table->dropPrimary(['id','payment_id','site_id']);
$table->dropIndex('fk_pi_pay_idx');
});
DB::statement('ALTER TABLE ab_payment_item RENAME TO payment_items');
Schema::table('ab_payment', function (Blueprint $table) {
$table->dropPrimary(['id','checkout_id','account_id','site_id']);
$table->dropUnique('UNIQUE');
});
DB::statement('ALTER TABLE ab_payment RENAME TO payments');
DB::statement('ALTER TABLE payment_items ADD PRIMARY KEY (id,site_id), MODIFY COLUMN id bigint auto_increment');
DB::statement('ALTER TABLE payments ADD PRIMARY KEY (id,site_id), MODIFY COLUMN id bigint auto_increment');
DB::statement('ALTER TABLE payments RENAME COLUMN date_payment TO payment_date');
Schema::table('payment_items', function (Blueprint $table) {
$table->unique(['site_id','payment_id','invoice_id']);
$table->foreign(['payment_id','site_id'])->references(['id','site_id'])->on('payments');
});
Schema::table('payments', function (Blueprint $table) {
$table->unique(['site_id','id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
abort(500,'cant go back');
}
}

View File

@ -1,50 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class ReworkCharges extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('ab_charge', function (Blueprint $table) {
$table->dropForeign('fk_chg_acc');
$table->dropForeign('fk_chg_pdt');
$table->dropForeign('fk_chg_svc');
$table->dropIndex('fk_chg_acc_idx');
$table->dropIndex('fk_chg_svc_idx');
$table->dropIndex('fk_chg_pdt_idx');
$table->dropPrimary(['id','account_id','site_id']);
});
DB::statement('ALTER TABLE ab_charge RENAME TO charges');
DB::statement('ALTER TABLE charges RENAME COLUMN date_charge TO charge_date');
Schema::table('charges', function (Blueprint $table) {
$table->unique(['id','account_id','site_id']);
$table->foreign(['account_id','site_id'])->references(['id','site_id'])->on('accounts');
$table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('ab_service');
$table->foreign(['product_id','site_id'])->references(['id','site_id'])->on('ab_product');
$table->integer('user_id')->unsigned()->nullable();
$table->foreign(['user_id','site_id'])->references(['id','site_id'])->on('users');
});
DB::statement('ALTER TABLE charges MODIFY COLUMN id INT auto_increment');
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
abort(500,'cant go back');
}
}

View File

@ -1,67 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CleanupSite extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('sites', function (Blueprint $table) {
$table->dropColumn(['date_orig']);
});
DB::statement('ALTER TABLE ab_country RENAME TO countries');
DB::statement('ALTER TABLE countries MODIFY id int(11) NOT NULL;');
DB::statement('ALTER TABLE countries MODIFY name varchar(128) NOT NULL;');
DB::statement('ALTER TABLE countries MODIFY notes text DEFAULT NULL;');
DB::statement('ALTER TABLE ab_currency RENAME TO currencies');
DB::statement('ALTER TABLE currencies MODIFY id int(11) NOT NULL;');
DB::statement('ALTER TABLE currencies MODIFY name varchar(128) NOT NULL;');
DB::statement('ALTER TABLE currencies MODIFY notes text DEFAULT NULL;');
DB::statement('ALTER TABLE currencies RENAME COLUMN convert_array TO rates;');
DB::statement('ALTER TABLE ab_language RENAME TO languages');
Schema::table('countries', function (Blueprint $table) {
$table->dropColumn(['description']);
$table->foreign(['currency_id'])->references(['id'])->on('currencies');
});
Schema::table('currencies', function (Blueprint $table) {
$table->dropForeign('fk_cur_cty');
$table->dropIndex('fk_cur_cty_idx');
$table->dropColumn(['country_id']);
});
DB::statement('ALTER TABLE ab_tax RENAME TO taxes');
DB::statement('ALTER TABLE taxes MODIFY description text DEFAULT NULL;');
DB::statement('ALTER TABLE taxes MODIFY id int(11) NOT NULL;');
DB::statement('ALTER TABLE taxes MODIFY country_id int(11) NOT NULL;');
Schema::table('taxes', function (Blueprint $table) {
$table->dropColumn(['date_orig','date_last','tax_id_collect','tax_id_name','tax_id_req','tax_id_exempt','tax_id_regex']);
$table->dropIndex('fk_tax_cty_idx');
$table->dropForeign('fk_tax_cty');
$table->foreign(['country_id'])->references(['id'])->on('countries');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
abort(500,'Cant go back');
}
}

View File

@ -1,55 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateSuppliers extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('suppliers', function (Blueprint $table) {
$table->integer('id',TRUE)->unsigned();
$table->boolean('active');
$table->string('name')->unique();
$table->string('address1');
$table->string('address2')->nullable();
$table->string('city',64);
$table->string('state',32);
$table->string('postcode',8);
});
Schema::create('supplier_details', function (Blueprint $table) {
$table->integer('id',TRUE)->unsigned();
$table->timestamps();
$table->text('notes')->nullable();
$table->string('accounts')->nullable();
$table->string('support')->nullable();
$table->string('payments')->nullable();
$table->integer('supplier_id')->unsigned();
$table->integer('site_id');
$table->unique(['supplier_id','site_id']);
$table->foreign(['supplier_id'])->references(['id'])->on('suppliers');
$table->foreign(['site_id'])->references(['id'])->on('sites');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('supplier_details');
Schema::dropIfExists('suppliers');
}
}

View File

@ -1,369 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/*
| ab_account_billing |
| ab_account_group |
| ab_account_log |
| ab_account_memo |
| ab_account_oauth |
| product_broadband |*DONE*
| supplier_broadband |*DONE*
| ab_affiliate |
| ab_asset |
| ab_asset_pool |
| ab_cart |
| ab_checkout |
| ab_checkout_notify |
| ab_discount |
| ab_domain_registrar |
| ab_domain_tld |
| ab_email_log |
| ab_email_setup |
| ab_email_template |
| ab_email_template_translate |
| ab_export |
| ab_export_datamap |
| ab_export_item |
| ab_export_module |
| ab_group |
| ab_group_method |
| ab_host_server |
| ab_host_server_affiliate |
| ab_host_server_id |
| ab_host_tld_id |
| ab_import |
| ab_invoice |
| ab_invoice_item |
| ab_invoice_item_discount |
| ab_invoice_item_tax |
| ab_invoice_memo |
| ab_log_error |
| ab_module |
| ab_module_method |
| ab_module_method_token |
| ab_oauth |
| ab_pivot_product_cat |
| products |*PARTIAL* - make model/model_id NOT NULL
| ab_product_cat |
| ab_product_cat_translate |
| ab_product_translate |
| ab_record_id |
| rtm |*DONE*
| ab_service |
| ab_service__adsl |
| ab_service__adsl_traffic |
| ab_service__hosting |
| ab_service__ssl |
| ab_service__voip |
| ab_service_change |
| ab_service_memo |
| ab_setup_invoice |
| ab_ssl |
| ab_ssl_ca |
| ab_static_page |
| ab_static_page_category |
| ab_static_page_translate |
| ab_task |
| ab_task_log |
| ab_voip_plan |
| accounts |*PARTIAL* - make timestamp columns, make date_expire timestamp
| charges |
| countries |*DONE*
| currencies |*DONE*
| external_account |
| external_integrations |
| failed_jobs |*N/A*
| invites |
| jobs |*N/A*
| languages |*DONE*
| migrations |*N/A*
| oauth_access_tokens |
| oauth_auth_codes |
| oauth_clients |
| oauth_personal_access_clients |
| oauth_refresh_tokens |
| password_resets |
| payment_items |
| payments |
| quickbooks_tokens |
| service__generic |
| service_domains |
| site_details |*DONE*
| sites |*DONE*
| supplier_details |*DONE*
| suppliers |*DONE*
| taxes |*DONE*
| users |*DONE*
*/
class IntUnsigned extends Migration
{
public function up()
{
$constraints = [
'ab_account_billing' => ['fk_ab_a','fk_ab_s'],
'ab_account_group' => ['fk_ag_acc','fk_ag_grp'],
'ab_account_log' => ['fk_al_acc'],
'ab_account_oauth' => ['fk_ao_a','fk_ao_o','site_user_id'],
'ab_adsl_plan' => ['fk_ap_asp'],
'ab_adsl_supplier' => ['fk_as_set'],
'ab_adsl_supplier_plan' => ['fk_asp_as'],
'ab_affiliate' => ['fk_aff_acc'],
'ab_cart' => ['fk_mod_crt'],
'ab_checkout' => ['fk_cko_set'],
'ab_checkout_notify' => ['fk_cn_c'],
'ab_domain_tld' => ['fk_ht_hrp'],
'ab_email_log' => ['fk_el_acc','fk_el_ett','fk_el_mod'],
'ab_email_setup' => ['fk_es_acc'],
'ab_email_template' => ['fk_et_es'],
'ab_email_template_translate' => ['fk_emt_et','fk_emt_lan'],
'ab_export' => ['fk_exp_set'],
'ab_export_datamap' => ['fk_edm_exm','fk_edm_mod'],
'ab_export_item' => ['fk_eit_exm'],
'ab_export_module' => ['fk_exm_exp','fk_exm_mod'],
'ab_group' => ['fk_grp_set'],
'ab_group_method' => ['fk_gm_grp','fk_gm_mm'],
'ab_host_server_affiliate' => ['fk_hsa_aff','fk_hsa_hs'],
'ab_invoice' => ['fk_inv_acc'],
'ab_invoice_item' => ['fk_ii_inv','fk_ii_mod','fk_ii_pdt','fk_ii_svc'],
'ab_invoice_item_tax' => ['fk_iit_ii','fk_iit_tax'],
'ab_invoice_memo' => ['fk_im_acc','fk_im_inv'],
'ab_module' => ['fk_mod','fk_mod_set'],
'ab_module_method' => ['fk_mm_mod'],
'ab_module_method_token' => ['fk_mmt_acc','fk_mmt_mm'],
'ab_oauth' => ['fk_o_set'],
'ab_pivot_product_cat' => ['fk_p','fk_pc'],
'ab_product' => ['fk_pdt_set'],
'ab_product_cat_translate' => ['fk_pct_lan','fk_pct_pc'],
'ab_product_cat' => ['fk_pc_pc','fk_pc_set'],
'ab_product_translate' => ['fk_pt_l','fk_pt_p'],
'ab_record_id' => ['fk_rid_mod','fk_rid_set'],
'rtm' => ['fk_rtm_acc','fk_rtm_rtm'],
'ab_service__adsl_traffic' => ['ab_service__adsl_traffic_ab_service_adsl_id_foreign','fk_sat_as'],
'ab_service__adsl' => ['fk_sa_ap','fk_sa_svc'],
'ab_service__hosting' => ['fk_sh_svc','fk_sh_ht','fk_sh_hs'],
'ab_service__ssl' => ['fk_ss_sca','fk_ss_svc'],
'ab_service_change' => ['fk_sc_a','fk_sc_p','fk_sc_s'],
'ab_service_memo' => ['fk_sm_acc','fk_sm_svc'],
'ab_service' => ['ab_service_orderby_id_foreign','fk_svc_acc','fk_svc_grp'],
'ab_ssl' => ['fk_ssl_set'],
'ab_ssl_ca' => ['fk_sca','fk_sca_acc'],
'ab_task_log' => ['fk_tl_t'],
'ab_task' => ['fk_tsk_set'],
'accounts' => ['ab_account_user_id_foreign','fk_acc_cty','fk_acc_cur','fk_acc_lan','fk_acc_rtm','fk_acc_set'],
'charges' => ['charges_account_id_site_id_foreign','charges_product_id_site_id_foreign','charges_service_id_site_id_foreign','charges_user_id_site_id_foreign'],
'countries' => ['countries_currency_id_foreign'],
'external_account' => ['external_account_account_id_foreign','external_account_external_integration_id_foreign','external_account_site_id_foreign'],
'external_integrations' => ['external_integrations_user_id_foreign'],
'payment_items' => ['fk_pi_inv','payment_items_payment_id_site_id_foreign'],
'payments' => ['fk_pay_acc','fk_pay_acc_b','fk_pay_co'],
'quickbooks_tokens' => ['quickbooks_tokens_user_id_foreign'],
'service__generic' => ['service__generic_product_id_site_id_foreign','service__generic_service_id_site_id_foreign','service__generic_site_id_foreign'],
'service_domains' => ['fk_sd_hrp','fk_sd_ht','fk_sd_svc'],
'site_details' => ['site_details_site_id_foreign'],
'sites' => ['sites_admin_id_site_id_foreign','sites_country_id_foreign','sites_currency_id_foreign','sites_language_id_foreign'],
'supplier_details' => ['supplier_details_site_id_foreign','supplier_details_supplier_id_foreign'],
'taxes' => ['taxes_country_id_foreign'],
'users' => ['users_currency_id_foreign','users_language_id_foreign','users_parent_id_foreign'],
];
$indexes = [
'ab_account_billing' => ['fk_ab_a','fk_ab_s','UNIQUE'],
'ab_account_group' => ['fk_ag_acc_idx','fk_ag_grp_idx','UNIQUE'],
'ab_account_log' => ['fk_al_acc_idx'],
'ab_account_memo' => ['memo','account','IDS'],
'ab_account_oauth' => ['fk_ao_a_idx','fk_ao_o_idx','site_user_id_idx','ab_account_oauth_site_id_user_id_oauth_id_unique','UNIQUE'],
'ab_adsl_supplier_plan' => ['fk_asp_as_idx'],
'ab_adsl_supplier' => ['fk_as_set_idx'],
'ab_adsl_plan' => ['fk_ap_asp_idx'],
'ab_affiliate' => ['fk_aff_acc_idx'],
'ab_asset_pool' => ['main','IDS'],
'ab_asset' => ['assets','asso','service','asset','IDS'],
'ab_cart' => ['fk_mod_crt_idx'],
'ab_checkout_notify' => ['fk_cn_c_idx'],
'ab_checkout' => ['fk_cko_set_idx'],
'ab_discount' => ['start','expire','status','IDS'],
'ab_domain_registrar' => ['fk_hrp_set','IDS'],
'ab_domain_tld' => ['fk_ht_hrp_idx'],
'ab_email_log' => ['fk_el_acc_idx','fk_el_ett_idx','fk_el_mod_idx'],
'ab_email_setup' => ['fk_es_acc_idx'],
'ab_email_template_translate' => ['fk_emt_et_idx','fk_emt_lan_idx'],
'ab_email_template' => ['fk_et_es_idx'],
'ab_export_datamap' => ['fk_edm_mod_idx','fk_edm_mod_idx1','UNIQUE'],
'ab_export_item' => ['fk_exp_eit_idx','UNIQUE'],
'ab_export_module' => ['fk_exp_exm_idx','fk_exp_mod_idx'],
'ab_export' => ['fk_exp_set_idx','UNIQUE'],
'ab_group_method' => ['fk_gm_grp_idx','fk_gm_mm_idx','UNIQUE'],
'ab_group' => ['fk_grp_set_idx'],
'ab_host_server' => ['IDS'],
'ab_host_server_affiliate' => ['fk_hsa_aff_idx','fk_hsa_hs_idx'],
'ab_import' => ['IDS'],
'ab_invoice_item_discount' => ['discounts','invoice_id','dates','accounts','IDS'],
'ab_invoice_item_tax' => ['fk_iit_ii_idx','fk_iit_tax_idx'],
'ab_invoice_item' => ['fk_ii_inv_idx','fk_ii_mod_idx','fk_ii_pdt_idx','fk_ii_svc_idx','UNIQUE'],
'ab_invoice_memo' => ['fk_im_acc_idx','fk_im_inv_idx'],
'ab_invoice' => ['fk_inv_acc_idx'],
'ab_log_error' => ['IDS'],
'ab_module_method_token' => ['fk_mmt_acc_idx','fk_mmt_mm_idx'],
'ab_module_method' => ['fk_mm_mod_idx','UNIQUE','UNIQUE2'],
'ab_module' => ['fk_mod_idx','fk_mod_set_idx','UNIQUE'],
'ab_oauth' => ['fk_o_set_idx','ab_oauth_site_id_name_unique'],
'ab_pivot_product_cat' => ['fk_p_idx','fk_pc_idx','UNIQUE'],
'ab_product_cat' => ['fk_pc_pc_idx','fk_pc_set_idx'],
'ab_product' => ['fk_pdt_set_idx'],
'ab_product_cat_translate' => ['fk_pct_lan_idx','fk_pct_pc_idx','UNIQUE'],
'ab_product_translate' => ['fk_pt_l_idx','fk_pt_p_idx','UNIQUE'],
'ab_record_id' => ['fk_rid_mod_idx','fk_rid_set_idx'],
'rtm' => ['fk_rtm_set_idx','fk_rtm_acc_p_idx','uq_name'],
'ab_service' => ['ab_service_orderby_id_foreign','fk_svc_acc_idx','fk_svc_grp_idx','UNIQUE'],
'ab_service__adsl' => ['fk_service_number','fk_sa_svc_idx','fk_sa_ap_idx','uq_service_username','UNIQUE'],
'ab_service__adsl_traffic' => ['fk_sat_as_idx','in_sat_SERVICE_DATE','in_sat_DATE','in_sat_SERVICE','ab_service__adsl_traffic_ab_service_adsl_id_date_time_unique'],
'ab_service__hosting' => ['fk_sh_hs_idx','fk_domain_tld_id','fk_service_id','uq_ftp_username','UNIQUE'],
'ab_service__ssl' => ['fk_ss_sca_idx','fk_ss_svc_idx','UNIQUE'],
'ab_service_change' => ['fk_s_sc_idx','fk_s_p_idx','fk_sc_a_idx'],
'ab_service_memo' => ['fk_sm_acc_idx','fk_sm_svc_idx'],
'ab_setup_invoice' => ['IDS'],
'ab_ssl' => ['fk_ssl_set_idx'],
'ab_ssl_ca' => ['fk_sca_idx','fk_sca_acc_idx'],
'ab_static_page' => ['cat','start','expire','name','IDS'],
'ab_static_page_category' => ['status','name','IDS'],
'ab_static_page_translate' => ['IDS'],
'ab_task' => ['fk_tsk_set_idx'],
'ab_task_log' => ['fk_tl_task'],
'accounts' => ['ab_account_user_id_foreign','fk_acc_set_idx','fk_acc_lan_idx','fk_acc_rtm_idx','fk_acc_cty_idx','fk_acc_cur_idx'],
'charges' => ['charges_account_id_site_id_foreign','charges_product_id_site_id_foreign','charges_service_id_site_id_foreign','charges_user_id_site_id_foreign'],
'countries' => ['countries_currency_id_foreign','name_UNIQUE','two_code_UNIQUE','three_code_UNIQUE'],
'currencies' => ['three_digit_UNIQUE'],
'external_account' => ['external_account_external_integration_id_foreign','external_account_account_id_foreign','sae'],
'external_integrations' => ['external_integrations_user_id_foreign'],
'languages' => ['name_UNIQUE','iso_UNIQUE'],
'payment_items' => ['fk_pi_inv_idx','payment_items_payment_id_site_id_foreign','payment_items_site_id_payment_id_invoice_id_unique'],
'payments' => ['fk_pay_acc_idx','fk_pay_cp_idx','fk_pay_acc_b_idx','payments_site_id_id_unique'],
'quickbooks_tokens' => ['quickbooks_tokens_user_id_foreign'],
'service__generic' => ['service__generic_service_id_site_id_foreign','service__generic_product_id_site_id_foreign','service__generic_site_id_service_id_unique'],
'service_domains' => ['fk_sd_svc_idx','fk_sd_hrp_idx','fk_sd_ht_idx','UNIQUE'],
'site_details' => ['site_details_site_id_key_unique'],
'sites' => ['sites_site_id_index','sites_admin_id_site_id_foreign','sites_country_id_foreign','sites_currency_id_foreign','sites_language_id_foreign','sites_site_id_url_unique'],
'supplier_details' => ['supplier_details_site_id_foreign','supplier_details_supplier_id_site_id_unique'],
'taxes' => ['UNIQUE'],
'users' => ['users_site_id_email_unique','users_parent_id_foreign','users_language_id_foreign','users_currency_id_foreign','site_user_id_idx'],
];
Schema::dropIfExists('ab_host_server_id');
Schema::dropIfExists('ab_host_tld_id');
DB::statement('ALTER TABLE ab_rtm RENAME TO rtm');
foreach ($constraints as $table => $constraint) {
Schema::table($table, function (Blueprint $table) use ($constraint) {
foreach ($constraint as $item)
$table->dropForeign($item);
});
}
foreach ($indexes as $table => $constraint) {
Schema::table($table, function (Blueprint $table) use ($constraint) {
foreach ($constraint as $item)
$table->dropIndex($item);
});
}
$tables = collect(array_unique(array_merge(array_keys($constraints),array_keys($indexes))));
$except = [
'ab_group','ab_record_id','ab_service__adsl_traffic','accounts','external_account','site_details',
'ab_account_memo','ab_asset_pool','ab_asset','ab_discount','ab_host_server','ab_import','ab_invoice_item_discount',
'ab_log_error','ab_setup_invoice','ab_static_page','ab_static_page_category','ab_static_page_translate',
'ab_email_template',
];
foreach ($tables->diff($except) as $table) {
DB::statement(sprintf('ALTER TABLE %s MODIFY id int unsigned auto_increment',$table));
if (Schema::hasColumn($table,'site_id')) {
DB::statement(sprintf('ALTER TABLE %s MODIFY site_id int unsigned NOT NULL',$table));
}
}
Schema::table('sites', function (Blueprint $table) {
$table->index(['site_id']);
});
foreach ($tables->diff($except)->diff(['sites']) as $table) {
if (Schema::hasColumn($table,'site_id')) {
dump($table);
Schema::table($table, function (Blueprint $table) {
$table->foreign(['site_id'])->references(['site_id'])->on('sites');
$table->index(['id','site_id']);
});
}
}
DB::statement('ALTER TABLE currencies RENAME COLUMN iso_code TO iso');
Schema::table('currencies', function (Blueprint $table) {
$table->unique(['name']);
$table->unique(['iso']);
});
Schema::table('languages', function (Blueprint $table) {
$table->unique(['name']);
$table->unique(['iso']);
});
DB::statement('ALTER TABLE countries MODIFY currency_id int unsigned');
Schema::table('countries', function (Blueprint $table) {
$table->foreign(['currency_id'])->references(['id'])->on('currencies');
$table->index(['id','currency_id']);
$table->unique(['name']);
$table->unique(['two_code']);
$table->unique(['three_code']);
});
DB::statement('ALTER TABLE users MODIFY country_id int unsigned NOT NULL,MODIFY language_id int unsigned NOT NULL,MODIFY currency_id int unsigned NOT NULL');
Schema::table('users', function (Blueprint $table) {
$table->dropColumn(['currency_id']);
$table->foreign(['country_id'])->references(['id'])->on('countries');
$table->foreign(['parent_id','site_id'])->references(['id','site_id'])->on('users');
$table->foreign(['language_id'])->references(['id'])->on('languages');
});
DB::statement('DELETE FROM accounts WHERE id=0');
DB::statement('ALTER TABLE accounts MODIFY id int unsigned auto_increment');
DB::statement('ALTER TABLE accounts MODIFY site_id int unsigned NOT NULL');
DB::statement('ALTER TABLE accounts MODIFY country_id int unsigned NOT NULL,MODIFY language_id int unsigned NOT NULL,MODIFY currency_id int unsigned NOT NULL,MODIFY rtm_id int unsigned DEFAULT NULL,MODIFY active tinyint(1) NOT NULL');
Schema::table('accounts', function (Blueprint $table) {
$table->dropColumn(['currency_id','language_id']);
$table->foreign(['site_id'])->references(['site_id'])->on('sites');
$table->index(['id','site_id']);
$table->foreign(['country_id'])->references(['id'])->on('countries');
$table->foreign(['user_id','site_id'])->references(['id','site_id'])->on('users');
$table->foreign(['rtm_id','site_id'])->references(['id','site_id'])->on('rtm');
});
DB::statement('ALTER TABLE rtm MODIFY account_id int unsigned NOT NULL,MODIFY parent_id int unsigned');
Schema::table('rtm', function (Blueprint $table) {
$table->foreign(['parent_id','site_id'])->references(['id','site_id'])->on('rtm');
$table->foreign(['account_id','site_id'])->references(['id','site_id'])->on('accounts');
});
DB::statement('ALTER TABLE sites MODIFY country_id int unsigned NOT NULL,MODIFY language_id int unsigned NOT NULL,MODIFY currency_id int unsigned NOT NULL');
Schema::table('sites', function (Blueprint $table) {
$table->foreign(['country_id','currency_id'])->references(['id','currency_id'])->on('countries');
$table->foreign(['admin_id','site_id'])->references(['id','site_id'])->on('users');
$table->foreign(['language_id'])->references(['id'])->on('languages');
});
DB::statement('ALTER TABLE site_details MODIFY site_id int unsigned NOT NULL');
Schema::table('site_details', function (Blueprint $table) {
$table->foreign(['site_id'])->references(['id'])->on('sites');
$table->unique(['site_id','key']);
});
DB::statement('ALTER TABLE taxes MODIFY country_id int unsigned NOT NULL');
Schema::table('taxes', function (Blueprint $table) {
$table->foreign(['country_id'])->references(['id'])->on('countries');
$table->unique(['country_id','zone']);
});
}
}

View File

@ -1,632 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class OptimizeProduct extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$site = \App\Models\Site::where('site_id',1)->firstOrNew();
Schema::table('ab_product', function (Blueprint $table) {
$table->dropForeign(['site_id']);
$table->dropIndex(['id','site_id']);
$table->dropIndex('ab_product_site_id_foreign');
});
DB::statement('ALTER TABLE ab_product RENAME TO products');
Schema::table('products', function (Blueprint $table) {
$table->dropColumn(['cart_multiple']);
$table->index(['id','site_id']);
$table->foreign(['site_id'])->references(['id'])->on('sites');
$table->dateTime('created_at')->nullable()->after('id');
$table->dateTime('updated_at')->nullable()->after('created_at');
});
DB::statement('ALTER TABLE suppliers MODIFY address1 varchar(255),MODIFY city varchar(255),MODIFY state varchar(255),MODIFY postcode varchar(255)');
Schema::table('supplier_details', function (Blueprint $table) {
$table->jsonb('connections')->nullable();
});
foreach (\Illuminate\Support\Facades\DB::select('SELECT * FROM ab_adsl_supplier') as $o) {
switch($o->name) {
case 'PeopleAgent':
$type = 'broadband';
$name = 'People Telecom';
break;
case 'iiNetADSL':
$type = 'broadband';
$name = 'iiNet';
break;
case 'ExetelVisp':
$type = 'broadband';
$name = 'Exetel';
break;
case 'ExetelHSPA':
$type = 'hspa';
$name = 'Exetel';
break;
case 'ExetelPE':
$type = 'ethernet';
$name = 'Exetel';
break;
default:
throw new Exception('Unknown Supplier: '.$o->name);
}
$so = \App\Models\Supplier::where('name',$name)->singleOrNew();
$so->name = $name;
$so->active = $so->active ?: $o->active;
$so->save();
$sdo = \App\Models\SupplierDetail::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)
->where('supplier_id',$so->id)
->where('site_id',$o->site_id)
->firstOrNew();
if (! $sdo->exists) {
$sdo->site_id = $o->site_id;
}
$connections = $sdo->connections ?: collect();
$connections->put($type,[
'user'=>$o->stats_username,
'pass'=>$o->stats_password,
'last'=>$o->stats_lastupdate,
'url'=>$o->stats_url,
]);
$sdo->connections = $connections;
$so->detail()->save($sdo);
};
Schema::table('ab_adsl_supplier_plan', function (Blueprint $table) {
$table->dropForeign(['site_id']);
$table->dropIndex(['id','site_id']);
$table->dropIndex('ab_adsl_supplier_plan_site_id_foreign');
});
DB::statement('ALTER TABLE ab_adsl_supplier_plan RENAME TO supplier_broadband');
DB::statement('ALTER TABLE supplier_broadband MODIFY product_id varchar(16) NOT NULL');
DB::statement('ALTER TABLE supplier_broadband MODIFY base_cost double NOT NULL');
DB::statement('ALTER TABLE supplier_broadband MODIFY active tinyint(1)');
DB::statement('ALTER TABLE supplier_broadband RENAME COLUMN supplier_id TO old_supplier_id');
DB::statement('ALTER TABLE supplier_broadband RENAME COLUMN offpeak_start TO old_offpeak_start');
DB::statement('ALTER TABLE supplier_broadband RENAME COLUMN offpeak_end TO old_offpeak_end');
Schema::table('supplier_broadband', function (Blueprint $table) {
$table->index(['id','site_id']);
$table->foreign(['site_id'])->references(['id'])->on('sites');
$table->dateTime('created_at')->nullable()->after('id');
$table->dateTime('updated_at')->nullable()->after('created_at');
$table->time('offpeak_start')->nullable()->after('old_offpeak_end');
$table->time('offpeak_end')->nullable()->after('offpeak_start');
});
Schema::table('supplier_broadband', function (Blueprint $table) {
$table->integer('supplier_detail_id')->unsigned()->nullable()->after('old_supplier_id');
$table->foreign(['supplier_detail_id','site_id'])->references(['id','site_id'])->on('supplier_details');
});
\Illuminate\Support\Facades\DB::select("UPDATE ab_service SET model='App\\\\Models\\\\Service\\\\Broadband' where model='App\\\\Models\\\\Service\\\\Adsl'");
\Illuminate\Support\Facades\DB::select("UPDATE products SET model='App\\\\Models\\\\Product\\\\Broadband' where model='App\\\\Models\\\\Product\\\\Adsl'");
// Convert to use the new supplier
foreach (\Illuminate\Support\Facades\DB::select('SELECT * FROM ab_adsl_supplier') as $o) {
switch ($o->name) {
case 'PeopleAgent':
$so = \App\Models\Supplier::where('name','People Telecom')->singleOrFail();
break;
case 'iiNetADSL':
$so = \App\Models\Supplier::where('name','iiNet')->singleOrFail();
break;
case 'ExetelVisp':
case 'ExetelHSPA':
case 'ExetelPE':
$so = \App\Models\Supplier::where('name','Exetel')->singleOrFail();
break;
default:
throw new Exception('Unknown Supplier: ' . $o->name);
}
$sdo = \App\Models\SupplierDetail::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)
->where('supplier_id',$so->id)
->where('site_id',$o->site_id)
->singleOrFail();
\Illuminate\Support\Facades\DB::select(sprintf("UPDATE supplier_broadband SET supplier_detail_id=%d where old_supplier_id=%d and site_id=%d",$sdo->id,$o->id,$sdo->site_id));
}
// Convert out dates
foreach (\App\Models\Supplier\Broadband::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)->cursor() as $o) {
if ($o->date_orig)
$o->created_at = \Carbon\Carbon::createFromTimestamp($o->date_orig);
if ($o->date_last)
$o->updated_at = \Carbon\Carbon::createFromTimestamp($o->date_last);
if ($o->old_offpeak_start)
$o->offpeak_start = \Carbon\Carbon::createFromTimestamp($o->old_offpeak_start);
if ($o->old_offpeak_end)
$o->offpeak_end = \Carbon\Carbon::createFromTimestamp($o->old_offpeak_end);
$o->save();
}
Schema::table('supplier_broadband', function (Blueprint $table) {
$table->dropPrimary();
$table->primary(['id','site_id']);
$table->dropColumn(['date_orig','date_last','old_supplier_id','old_offpeak_start','old_offpeak_end']);
});
Schema::dropIfExists('ab_adsl_supplier');
DB::statement('ALTER TABLE supplier_broadband MODIFY extra_charged tinyint(1)');
DB::statement('ALTER TABLE supplier_broadband MODIFY extra_shaped tinyint(1)');
DB::statement('ALTER TABLE supplier_broadband MODIFY contract_term int unsigned');
Schema::table('ab_adsl_plan', function (Blueprint $table) {
$table->dropForeign(['site_id']);
$table->dropIndex(['id','site_id']);
$table->dropIndex('ab_adsl_plan_site_id_foreign');
});
DB::statement('ALTER TABLE ab_adsl_plan RENAME TO product_broadband');
DB::statement('ALTER TABLE product_broadband DROP PRIMARY KEY,ADD PRIMARY KEY (id,site_id)');
DB::statement('ALTER TABLE product_broadband MODIFY extra_charged tinyint(1)');
DB::statement('ALTER TABLE product_broadband MODIFY extra_shaped tinyint(1)');
DB::statement('ALTER TABLE product_broadband MODIFY contract_term int unsigned');
DB::statement('ALTER TABLE product_broadband RENAME COLUMN adsl_supplier_plan_id TO supplier_broadband_id');
DB::statement('ALTER TABLE product_broadband MODIFY supplier_broadband_id int unsigned');
Schema::table('product_broadband', function (Blueprint $table) {
$table->index(['id','site_id']);
$table->foreign(['site_id'])->references(['id'])->on('sites');
$table->foreign(['supplier_broadband_id','site_id'])->references(['id','site_id'])->on('supplier_broadband');
$table->dateTime('created_at')->nullable()->after('id');
$table->dateTime('updated_at')->nullable()->after('created_at');
});
// Convert product pricegroups
foreach (\App\Models\Product::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)->cursor() as $po) {
if ($po->date_orig)
$po->created_at = \Carbon\Carbon::createFromTimestamp($po->date_orig);
if ($po->date_last)
$po->updated_at = \Carbon\Carbon::createFromTimestamp($po->date_last);
if (! ($po instanceof \Illuminate\Support\Collection) || ! $po->price_group->count()) {
$original = $po->getRawOriginal('price_group');
// serialized
if (preg_match('/^a:/',$original)) {
try {
$price_group = collect(unserialize(str_replace("\n","",$original)));
} catch (Exception $e) {
dd(['error'=>$e->getMessage(),'raw'=>$po->getRawOriginal('price_group')]);
}
} elseif (is_null($po->getRawOriginal('price_group'))) {
$price_group = collect();
} else {
try {
$price_group = unserialize(gzuncompress($po->getRawOriginal('price_group')));
} catch (Exception $e) {
dd(['error'=>$e->getMessage(),'raw'=>$po->getRawOriginal('price_group')]);
}
}
$new_price_group = collect();
// Remove any blank entries, or when base/setup = 0
foreach ($price_group as $group => $values) {
$build = collect();
foreach ($values as $key => $pricing) {
switch ($key) {
case 'show':
$build->put('show',(bool) $pricing);
break;
default:
// key is a time period
if ((! Arr::get($pricing,'price_base')) && (! Arr::get($pricing,'price_setup')))
break;
$build->put($key,[
'base'=>Arr::get($pricing,'price_base'),
'setup'=>Arr::get($pricing,'price_setup'),
]);
}
}
$new_price_group->put($group,$build);
}
$po->price_group = $new_price_group;
}
$po->save();
}
DB::statement('ALTER TABLE products MODIFY taxable tinyint(1),MODIFY active tinyint(1),MODIFY price_recurr_strict tinyint(1),MODIFY prod_plugin_data int unsigned');
DB::statement('ALTER TABLE products RENAME COLUMN price_group TO pricing');
DB::statement('ALTER TABLE products RENAME COLUMN price_recurr_default TO price_recur_default');
DB::statement('ALTER TABLE products RENAME COLUMN price_recurr_strict TO price_recur_strict');
DB::statement('ALTER TABLE products RENAME COLUMN prod_plugin_data TO model_id');
Schema::table('products', function (Blueprint $table) {
$table->dropColumn(['date_orig','date_last','group_avail','avail_category','price_recurr_day','price_recurr_weekday','prod_plugin_file']);
});
Schema::dropIfExists('ab_voip_plan');
Schema::create('tlds',function (Blueprint $table) {
$table->integer('id',TRUE)->unsigned();
$table->timestamps();
$table->string('name',64)->unique();
});
Schema::create('supplier_domain',function (Blueprint $table) {
$table->integer('id',TRUE)->unsigned();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active');
$table->integer('supplier_detail_id')->unsigned();
$table->string('product_id',16);
$table->string('product_desc',128)->nullable();
$table->float('base_cost');
$table->float('setup_cost')->nullable();
$table->integer('contract_term')->unsigned()->nullable();
$table->integer('tld_id')->unsigned();
$table->text('whois_url')->nullable();
$table->text('config')->nullable();
$table->index(['id','site_id']);
$table->foreign(['site_id'])->references(['id'])->on('sites');
$table->foreign(['tld_id'])->references(['id'])->on('tlds');
$table->foreign(['supplier_detail_id','site_id'])->references(['id','site_id'])->on('supplier_details');
});
Schema::create('supplier_host',function (Blueprint $table) {
$table->integer('id',TRUE)->unsigned();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active');
$table->integer('supplier_detail_id')->unsigned();
$table->string('product_id',16);
$table->string('product_desc',128)->nullable();
$table->float('base_cost');
$table->float('setup_cost')->nullable();
$table->integer('contract_term')->unsigned()->nullable();
$table->index(['id','site_id']);
$table->foreign(['site_id'])->references(['id'])->on('sites');
$table->foreign(['supplier_detail_id','site_id'])->references(['id','site_id'])->on('supplier_details');
});
Schema::create('supplier_ssl',function (Blueprint $table) {
$table->integer('id',TRUE)->unsigned();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active');
$table->integer('supplier_detail_id')->unsigned();
$table->string('product_id',16);
$table->string('product_desc',128)->nullable();
$table->float('base_cost');
$table->float('setup_cost')->nullable();
$table->integer('contract_term')->unsigned()->nullable();
$table->index(['id','site_id']);
$table->foreign(['site_id'])->references(['id'])->on('sites');
$table->foreign(['supplier_detail_id','site_id'])->references(['id','site_id'])->on('supplier_details');
});
Schema::create('supplier_generic',function (Blueprint $table) {
$table->integer('id',TRUE)->unsigned();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active');
$table->integer('supplier_detail_id')->unsigned();
$table->string('product_id',16);
$table->string('product_desc',128)->nullable();
$table->float('base_cost');
$table->float('setup_cost')->nullable();
$table->integer('contract_term')->unsigned()->nullable();
$table->index(['id','site_id']);
$table->foreign(['site_id'])->references(['id'])->on('sites');
$table->foreign(['supplier_detail_id','site_id'])->references(['id','site_id'])->on('supplier_details');
});
Schema::create('supplier_voip',function (Blueprint $table) {
$table->integer('id',TRUE)->unsigned();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active');
$table->integer('supplier_detail_id')->unsigned();
$table->string('product_id',16);
$table->string('product_desc',128)->nullable();
$table->float('base_cost');
$table->float('setup_cost')->nullable();
$table->integer('contract_term')->unsigned()->nullable();
$table->index(['id','site_id']);
$table->foreign(['site_id'])->references(['id'])->on('sites');
$table->foreign(['supplier_detail_id','site_id'])->references(['id','site_id'])->on('supplier_details');
});
Schema::create('product_domain',function (Blueprint $table) {
$table->integer('id',TRUE)->unsigned();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->integer('supplier_domain_id')->unsigned();
$table->string('name',64);
$table->integer('contract_term')->unsigned()->nullable();
$table->index(['id','site_id']);
$table->foreign(['site_id'])->references(['id'])->on('sites');
$table->foreign(['supplier_domain_id','site_id'])->references(['id','site_id'])->on('supplier_domain');
});
Schema::create('product_host',function (Blueprint $table) {
$table->integer('id',TRUE)->unsigned();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->integer('supplier_host_id')->unsigned();
$table->string('name',64);
$table->integer('contract_term')->unsigned()->nullable();
$table->index(['id','site_id']);
$table->foreign(['site_id'])->references(['id'])->on('sites');
$table->foreign(['supplier_host_id','site_id'])->references(['id','site_id'])->on('supplier_host');
});
Schema::create('product_ssl',function (Blueprint $table) {
$table->integer('id',TRUE)->unsigned();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->integer('supplier_ssl_id')->unsigned();
$table->string('name',64);
$table->integer('contract_term')->unsigned()->nullable();
$table->index(['id','site_id']);
$table->foreign(['site_id'])->references(['id'])->on('sites');
$table->foreign(['supplier_ssl_id','site_id'])->references(['id','site_id'])->on('supplier_ssl');
});
Schema::create('product_generic',function (Blueprint $table) {
$table->integer('id',TRUE)->unsigned();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->integer('supplier_generic_id')->unsigned();
$table->string('name',64);
$table->integer('contract_term')->unsigned()->nullable();
$table->index(['id','site_id']);
$table->foreign(['site_id'])->references(['id'])->on('sites');
$table->foreign(['supplier_generic_id','site_id'])->references(['id','site_id'])->on('supplier_generic');
});
Schema::create('product_voip',function (Blueprint $table) {
$table->integer('id',TRUE)->unsigned();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->integer('supplier_voip_id')->unsigned();
$table->string('name',64);
$table->integer('contract_term')->unsigned()->nullable();
$table->index(['id','site_id']);
$table->foreign(['site_id'])->references(['id'])->on('sites');
$table->foreign(['supplier_voip_id','site_id'])->references(['id','site_id'])->on('supplier_voip');
});
// Setup Domains
foreach (\Illuminate\Support\Facades\DB::select('SELECT * FROM ab_domain_tld') as $o) {
$oo = new \App\Models\TLD;
if ($o->date_orig)
$oo->created_at = \Carbon\Carbon::createFromTimestamp($o->date_orig);
if ($o->date_last)
$oo->created_at = \Carbon\Carbon::createFromTimestamp($o->date_last);
$oo->name = strtolower($o->name);
$oo->save();
};
foreach (\Illuminate\Support\Facades\DB::select('SELECT * FROM ab_domain_registrar') as $o) {
$so = \App\Models\Supplier::where('name',$o->name)->singleOrNew();
$so->name = $o->name;
$so->active = $so->active ?: $o->active;
$so->save();
$sdo = \App\Models\SupplierDetail::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)
->where('supplier_id',$so->id)
->where('site_id',1)
->firstOrNew();
$sdo->site_id = 1;
$connects = collect();
if ($o->whitelabel_url)
$connects->put('whitelabel_url',$o->whitelabel_url);
if ($o->manage_url)
$connects->put('manage_url',$o->manage_url);
$sdo->connections = $connects;
$so->detail()->save($sdo);
foreach (\App\Models\TLD::cursor() as $tldo) {
$sd = \App\Models\Supplier\Domain::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)
->where('tld_id',$tldo->id)
->where('site_id',$sdo->site_id)
->where('supplier_detail_id',$sdo->id)
->firstOrNew();
$sd->supplier_detail_id = $sdo->id;
$sd->tld_id = $tldo->id;
$sd->site_id = $sdo->site_id;
$sd->active = TRUE;
$sd->product_id = 'Domain Name';
$sd->product_desc = 'Domain Name License';
$sd->base_cost = '.01';
$sd->contract_term = 12;
$sd->save();
$pd = \App\Models\Product\Domain::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)
->where('site_id',$sdo->site_id)
->where('supplier_domain_id',$sd->id)
->firstOrNew();
$pd->supplier_domain_id = $sd->id;
$pd->site_id = $sd->site_id;
$pd->name = $sd->name;
$pd->save();
}
}
// No need to update tables, if we dont have a site setup yet.
if (! $site->exists)
return;
// SSL
$so = \App\Models\Supplier::where('name','Graytech Hosting Pty Ltd')->firstOrNew();
$so->name = 'Graytech Hosting Pty Ltd';
$so->active = TRUE;
$so->save();
$sdo = \App\Models\SupplierDetail::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)
->where('site_id','1')
->where('supplier_id',$so->id)
->firstOrNew();
$sdo->site_id = $site->site_id;
$so->detail()->save($sdo);
$o = new \App\Models\Supplier\SSL;
$o->site_id = $sdo->site_id;
$o->active = TRUE;
$o->product_id = 'Graytech SSL';
$o->base_cost = 0;
$o->setup_cost = 0;
$o->supplier_detail_id = $sdo->id;
$o->save();
$oo = new \App\Models\Product\SSL;
$oo->site_id = $sdo->site_id;
$oo->supplier_ssl_id = $o->id;
$oo->name = 'Graytech SSL';
$oo->save();
$o = new \App\Models\Supplier\Host;
$o->site_id = $sdo->site_id;
$o->active = TRUE;
$o->product_id = 'Graytech Hosting';
$o->base_cost = 0;
$o->setup_cost = 0;
$o->supplier_detail_id = $sdo->id;
$o->save();
$oo = new \App\Models\Product\Host;
$oo->site_id = $sdo->site_id;
$oo->supplier_host_id = $o->id;
$oo->name = 'Graytech Hosting';
$oo->save();
$so = \App\Models\Supplier::where('name','crazydomain')->firstOrFail();
$sdo = \App\Models\SupplierDetail::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)
->where('site_id','1')
->where('supplier_id',$so->id)
->firstOrNew();
$sdo->site_id = $site->site_id;
$so->detail()->save($sdo);
$o = new \App\Models\Supplier\Host;
$o->site_id = $sdo->site_id;
$o->active = TRUE;
$o->product_id = 'CD Host';
$o->base_cost = 0;
$o->supplier_detail_id = $sdo->id;
$o->save();
$oo = new \App\Models\Product\Host;
$oo->site_id = $sdo->site_id;
$oo->supplier_host_id = $o->id;
$oo->name = 'Crazy Domains Hosting';
$oo->save();
// VOIP
$so = \App\Models\Supplier::where('name','Exetel')->firstOrFail();
$sdo = \App\Models\SupplierDetail::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)
->where('site_id','1')
->where('supplier_id',$so->id)
->firstOrNew();
$sdo->site_id = $site->site_id;
$so->detail()->save($sdo);
$o = new \App\Models\Supplier\Phone;
$o->site_id = $sdo->site_id;
$o->active = TRUE;
$o->product_id = 'VOIP $10';
$o->base_cost = 9.09;
$o->setup_cost = 0;
$o->supplier_detail_id = $sdo->id;
$o->save();
$oo = new \App\Models\Product\Phone;
$oo->site_id = $sdo->site_id;
$oo->supplier_voip_id = $o->id;
$oo->name = 'VOIP $10';
$oo->save();
$o = new \App\Models\Supplier\Phone;
$o->site_id = $sdo->site_id;
$o->active = TRUE;
$o->product_id = 'VOIP';
$o->base_cost = 0;
$o->setup_cost = 0;
$o->supplier_detail_id = $sdo->id;
$o->save();
$oo = new \App\Models\Product\Phone;
$oo->site_id = $sdo->site_id;
$oo->supplier_voip_id = $o->id;
$oo->name = 'VOIP';
$oo->save();
$o = new \App\Models\Supplier\Phone;
$o->site_id = $sdo->site_id;
$o->active = TRUE;
$o->product_id = 'VOIP B-100';
$o->product_desc = 'VOIP Business 100 Lines';
$o->base_cost = 22.727;
$o->setup_cost = 0;
$o->supplier_detail_id = $sdo->id;
$o->save();
$oo = new \App\Models\Product\Phone;
$oo->site_id = $sdo->site_id;
$oo->supplier_voip_id = $o->id;
$oo->name = 'VOIP B-10';
$oo->save();
// Manually run this, since we havent worked out site_id when running migrate.
// update products set model_id=49,model='App\\Models\\Product\\Domain' where id=78;
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
abort(500,'Cant go back');
}
}

View File

@ -1,106 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class EmailSupplier extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('supplier_email', function (Blueprint $table) {
$table->integer('id',TRUE)->unsigned();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active');
$table->integer('supplier_detail_id')->unsigned();
$table->string('product_id');
$table->string('product_desc')->nullable();
$table->float('base_cost');
$table->float('setup_cost')->nullable();
$table->integer('contract_term')->nullable();
$table->foreign(['supplier_detail_id'])->references(['id'])->on('supplier_details');
$table->foreign(['site_id'])->references(['id'])->on('sites');
});
Schema::create('product_email', function (Blueprint $table) {
$table->integer('id',TRUE)->unsigned();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active');
$table->integer('supplier_email_id')->unsigned();
$table->string('product_id');
$table->string('product_desc')->nullable();
$table->float('base_cost');
$table->float('setup_cost')->nullable();
$table->integer('contract_term')->nullable();
$table->foreign(['supplier_email_id'])->references(['id'])->on('supplier_email');
$table->foreign(['site_id'])->references(['id'])->on('sites');
});
Schema::create('service_emails', function (Blueprint $table) {
$table->integer('id',TRUE)->unsigned();
$table->integer('site_id')->unsigned();
$table->integer('service_id')->unsigned();
$table->integer('tld_id')->unsigned();
$table->string('domain_name',128);
$table->date('expire_at')->nullable();
$table->string('admin_url')->nullable();
$table->string('admin_user')->nullable();
$table->string('admin_pass')->nullable();
$table->integer('accounts')->nullable();
$table->foreign(['site_id'])->references(['id'])->on('sites');
$table->foreign(['service_id'])->references(['id'])->on('ab_service');
$table->foreign(['tld_id'])->references(['id'])->on('tlds');
});
// Migrate email hosting from hosting table to service_email
// Setup Domains
foreach (\Illuminate\Support\Facades\DB::select("SELECT * FROM ab_service__hosting WHERE host_type='email'") as $o) {
$oo = new \App\Models\Service\Email;
foreach (['site_id','service_id'] as $item)
$oo->{$item} = $o->{$item};
$oo->tld_id = $o->domain_tld_id;
$oo->domain_name = strtolower($o->domain_name);
$oo->admin_user = strtolower($o->host_username);
$oo->admin_pass = $o->host_password;
$oo->expire_at = \Carbon\Carbon::createFromTimestamp($o->host_expire);
$oo->save();
\App\Models\Service::where('id',$o->service_id)->update(['model'=>get_class($oo)]);
};
\Illuminate\Support\Facades\DB::select("DELETE FROM ab_service__hosting WHERE host_type='email'");
// insert into suppliers value (null,1,'Google',null,null,null,null,null);
// insert into supplier_details values (null,now(),now(),null,null,null,null,14,1,null);
// insert into supplier_email values (null,now(),now(),1,1,13,'Legacy Email','Legacy Email',0,0,0);
// insert into product_email values (null,now(),now(),1,1,1,'Email Hosting',null,150,0,12);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
/*
Schema::dropIfExists('product_email');
Schema::dropIfExists('supplier_email');
Schema::dropIfExists('service_emails');
*/
abort(500,'cant go back');
}
}

View File

@ -1,345 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class RenameServiceTables extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('ab_service', function (Blueprint $table) {
$table->dropPrimary();
$table->dropForeign('ab_service_site_id_foreign');
$table->primary(['id','site_id']);
$table->dropIndex('ab_service_site_id_foreign');
$table->dropIndex('ab_service_id_site_id_index');
$table->datetime('created_at')->nullable()->after('id');
$table->datetime('updated_at')->nullable()->after('created_at');
$table->date('invoice_last_at')->nullable()->after('date_last_invoice');
$table->date('invoice_next_at')->nullable()->after('date_next_invoice');
$table->date('start_at')->nullable()->after('date_start');
$table->date('stop_at')->nullable()->after('date_end');
});
DB::statement('ALTER TABLE ab_service RENAME TO services');
DB::statement('ALTER TABLE services MODIFY account_id int unsigned NOT NULL');
DB::statement('ALTER TABLE services MODIFY account_billing_id int unsigned DEFAULT NULL');
DB::statement('ALTER TABLE services MODIFY product_id int unsigned NOT NULL');
DB::statement('UPDATE services SET taxable=1');
DB::statement('UPDATE services SET active=0 WHERE active IS NULL');
DB::statement('ALTER TABLE services MODIFY active tinyint(1) NOT NULL,MODIFY suspend_billing tinyint(1) DEFAULT NULL,MODIFY external_billing tinyint(1) DEFAULT NULL,MODIFY taxable tinyint(1) DEFAULT NULL');
DB::statement('ALTER TABLE services RENAME COLUMN orderby_id TO ordered_by');
DB::statement('ALTER TABLE services MODIFY ordered_by int unsigned');
// Convert out dates
foreach (\App\Models\Service::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)->cursor() as $o) {
if ($o->date_orig)
$o->created_at = \Carbon\Carbon::createFromTimestamp($o->date_orig);
if ($o->date_last)
$o->updated_at = \Carbon\Carbon::createFromTimestamp($o->date_last);
if ($o->date_last_invoice)
$o->invoice_last_at = \Carbon\Carbon::createFromTimestamp($o->date_last_invoice);
if ($o->date_next_invoice)
$o->invoice_next_at = \Carbon\Carbon::createFromTimestamp($o->date_next_invoice);
if ($o->date_start)
$o->start_at = \Carbon\Carbon::createFromTimestamp($o->date_start);
if ($o->date_end)
$o->stop_at = \Carbon\Carbon::createFromTimestamp($o->date_end);
$o->save();
}
Schema::table('services', function (Blueprint $table) {
$table->dropColumn(['date_orig','date_last','date_last_invoice','date_next_invoice','date_start','date_end','queue','price_group']);
$table->foreign(['account_id','site_id'])->references(['id','site_id'])->on('accounts');
$table->foreign(['product_id','site_id'])->references(['id','site_id'])->on('products');
$table->foreign(['ordered_by','site_id'])->references(['id','site_id'])->on('users');
$table->foreign(['site_id'])->references(['site_id'])->on('sites');
});
DB::statement('ALTER TABLE service_domains RENAME TO service_domain');
DB::statement('ALTER TABLE service_emails RENAME TO service_email');
Schema::table('ab_service_change', function (Blueprint $table) {
$table->dropPrimary();
$table->primary(['id','site_id']);
$table->dropForeign('ab_service_change_site_id_foreign');
$table->dropIndex('ab_service_change_site_id_foreign');
$table->dropIndex('ab_service_change_id_site_id_index');
});
DB::statement('ALTER TABLE ab_service_change RENAME TO service__change');
DB::statement('ALTER TABLE service__change MODIFY service_id int unsigned');
DB::statement('ALTER TABLE service__change MODIFY product_id int unsigned');
DB::statement('ALTER TABLE service__change MODIFY ordered_by int unsigned');
Schema::table('service__change', function (Blueprint $table) {
$table->date('ordered_at')->nullable()->after('ordered_by');
$table->date('effective_at')->nullable()->after('ordered_at');
$table->foreign(['product_id','site_id'])->references(['id','site_id'])->on('products');
$table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services');
$table->foreign(['ordered_by','site_id'])->references(['id','site_id'])->on('users');
});
// Convert out dates
foreach (\App\Models\ServiceChange::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)->cursor() as $o) {
if ($o->date_ordered)
$o->ordered_at = \Carbon\Carbon::createFromTimestamp($o->date_ordered);
if ($o->date_effective)
$o->effective_at = \Carbon\Carbon::createFromTimestamp($o->date_effective);
$o->save();
}
DB::statement('ALTER TABLE service__change MODIFY ordered_at int unsigned NOT NULL');
DB::statement('ALTER TABLE service__change MODIFY effective_at int unsigned NOT NULL');
Schema::table('service__change', function (Blueprint $table) {
$table->dropColumn(['date_ordered','date_effective']);
});
DB::statement('ALTER TABLE service__generic MODIFY service_id int unsigned NOT NULL');
DB::statement('ALTER TABLE service__generic MODIFY product_id int unsigned DEFAULT NULL');
DB::statement('UPDATE service__generic SET product_id=NULL WHERE product_id=0');
Schema::table('service__generic', function (Blueprint $table) {
$table->dropPrimary();
$table->primary(['id','site_id']);
$table->dropForeign('service__generic_site_id_foreign');
$table->dropIndex('service__generic_site_id_foreign');
$table->dropIndex('service__generic_id_site_id_index');
$table->foreign(['product_id','site_id'])->references(['id','site_id'])->on('products');
$table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services');
});
DB::statement('ALTER TABLE service_domain MODIFY service_id int unsigned NOT NULL');
DB::statement('ALTER TABLE service_domain MODIFY domain_tld_id int unsigned NOT NULL');
DB::statement('ALTER TABLE service_domain MODIFY domain_registrar_id int unsigned DEFAULT NULL');
DB::statement('ALTER TABLE service_domain MODIFY domain_name varchar(128) NOT NULL');
DB::statement('ALTER TABLE service_domain RENAME COLUMN domain_tld_id TO tld_id');
Schema::table('service_domain', function (Blueprint $table) {
$table->dropPrimary();
$table->primary(['id','site_id']);
$table->dropForeign('service_domains_site_id_foreign');
$table->dropIndex('service_domains_site_id_foreign');
$table->dropIndex('service_domains_id_site_id_index');
$table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services');
$table->foreign(['tld_id'])->references(['id'])->on('tlds');
$table->date('expire_at')->nullable()->after('domain_expire');
});
// Convert out dates
foreach (\App\Models\Service\Domain::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)->cursor() as $o) {
if ($o->domain_expire)
$o->expire_at = \Carbon\Carbon::createFromTimestamp($o->domain_expire);
$o->save();
}
Schema::table('service_domain', function (Blueprint $table) {
$table->dropColumn(['registrar_lastsync','domain_expire']);
});
DB::statement('ALTER TABLE service_email DROP PRIMARY KEY,ADD PRIMARY KEY (id,site_id)');
Schema::table('service_email', function (Blueprint $table) {
$table->unique(['domain_name','tld_id']);
$table->dropForeign('service_emails_site_id_foreign');
$table->dropForeign('service_emails_service_id_foreign');
$table->dropForeign('service_emails_tld_id_foreign');
$table->foreign(['tld_id'])->references(['id'])->on('tlds');
$table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services');
});
DB::statement('ALTER TABLE ab_service__hosting RENAME TO service_host');
DB::statement('ALTER TABLE service_host RENAME COLUMN domain_tld_id TO tld_id');
DB::statement('ALTER TABLE service_host MODIFY service_id int unsigned NOT NULL');
DB::statement('ALTER TABLE service_host MODIFY tld_id int unsigned NOT NULL');
DB::statement('ALTER TABLE service_host MODIFY host_server_id int unsigned DEFAULT NULL');
DB::statement('ALTER TABLE service_host MODIFY domain_name varchar(128) NOT NULL');
Schema::table('service_host', function (Blueprint $table) {
$table->dropPrimary();
$table->primary(['id','site_id']);
$table->dropForeign('ab_service__hosting_site_id_foreign');
$table->dropIndex('ab_service__hosting_site_id_foreign');
$table->dropIndex('ab_service__hosting_id_site_id_index');
$table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services');
$table->foreign(['tld_id'])->references(['id'])->on('tlds');
$table->date('expire_at')->nullable()->after('host_expire');
});
// Convert our dates
foreach (\App\Models\Service\Host::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)->cursor() as $o) {
if ($o->server_data && (strlen($o->server_data) > 8) && gzuncompress($o->server_data))
$o->server_data = NULL;
if ($o->host_expire)
$o->expire_at = \Carbon\Carbon::createFromTimestamp($o->host_expire);
$o->save();
}
Schema::table('service_host', function (Blueprint $table) {
$table->dropColumn(['host_expire','server_data_date']);
});
DB::statement('ALTER TABLE product_broadband RENAME COLUMN supplier_broadband_id TO supplier_item_id');
DB::statement('ALTER TABLE product_domain RENAME COLUMN supplier_domain_id TO supplier_item_id');
DB::statement('ALTER TABLE product_email RENAME COLUMN supplier_email_id TO supplier_item_id');
DB::statement('ALTER TABLE product_host RENAME COLUMN supplier_host_id TO supplier_item_id');
DB::statement('ALTER TABLE product_ssl RENAME COLUMN supplier_ssl_id TO supplier_item_id');
DB::statement('ALTER TABLE product_generic RENAME COLUMN supplier_generic_id TO supplier_item_id');
DB::statement('ALTER TABLE product_voip RENAME TO product_phone');
DB::statement('ALTER TABLE product_phone RENAME COLUMN supplier_voip_id TO supplier_item_id');
Schema::table('product_phone', function (Blueprint $table) {
$table->dropPrimary();
$table->primary(['id','site_id']);
$table->dropForeign('product_voip_supplier_voip_id_site_id_foreign');
$table->dropForeign('product_voip_site_id_foreign');
$table->dropIndex('product_voip_supplier_voip_id_site_id_foreign');
$table->dropIndex('product_voip_site_id_foreign');
$table->dropIndex('product_voip_id_site_id_index');
});
DB::statement('ALTER TABLE supplier_voip RENAME TO supplier_phone');
Schema::table('supplier_phone', function (Blueprint $table) {
$table->dropPrimary();
$table->primary(['id','site_id']);
$table->dropForeign('supplier_voip_supplier_detail_id_site_id_foreign');
$table->dropForeign('supplier_voip_site_id_foreign');
$table->dropIndex('supplier_voip_id_site_id_index');
$table->foreign(['supplier_detail_id','site_id'])->references(['id','site_id'])->on('supplier_details');
$table->string('technology')->nullable();
});
Schema::table('product_phone', function (Blueprint $table) {
$table->foreign(['supplier_item_id','site_id'])->references(['id','site_id'])->on('supplier_phone');
$table->string('technology')->nullable();
});
DB::statement('ALTER TABLE ab_service__voip RENAME TO service_phone');
DB::statement('ALTER TABLE service_phone MODIFY service_id int unsigned NOT NULL');
DB::statement('ALTER TABLE service_phone MODIFY service_number varchar(10) NOT NULL');
DB::statement('ALTER TABLE service_phone MODIFY site_id int unsigned NOT NULL');
Schema::table('service_phone', function (Blueprint $table) {
$table->primary(['id','site_id']);
$table->date('connect_at')->nullable()->after('contract_term');
$table->date('expire_at')->nullable()->after('connect_at');
$table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services');
$table->string('technology')->nullable();
});
DB::statement('ALTER TABLE service_phone MODIFY id int unsigned auto_increment');
// Convert our dates
foreach (\App\Models\Service\Phone::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)->cursor() as $o) {
if ($o->service_connect_date)
$o->connect_at = \Carbon\Carbon::createFromTimestamp($o->service_connect_date);
if ($o->getRawOriginal('contract_term') === 0)
$o->contract_term = NULL;
if ($o->service_contract_date && $o->getRawOriginal('contract_term'))
$o->expire_at = \Carbon\Carbon::createFromTimestamp($o->service_contract_date)->addMonths($o->getRawOriginal('contract_term'));
$o->save();
}
Schema::table('service_phone', function (Blueprint $table) {
$table->dropColumn(['service_connect_date','service_contract_date','contract_term']);
});
DB::statement('ALTER TABLE ab_service__adsl RENAME TO service_broadband');
DB::statement('ALTER TABLE service_broadband MODIFY service_id int unsigned NOT NULL');
DB::statement('ALTER TABLE service_broadband MODIFY service_stats_collect tinyint(1) DEFAULT NULL');
DB::statement('ALTER TABLE service_broadband RENAME COLUMN service_stats_lastupdate TO service_stats_at');
DB::statement('ALTER TABLE service_broadband RENAME COLUMN provided_adsl_plan_id TO provided_supplier_broadband_id');
DB::statement('ALTER TABLE service_broadband MODIFY provided_supplier_broadband_id int unsigned DEFAULT NULL');
// @todo drop column provided_adsl_plan_id
Schema::table('service_broadband', function (Blueprint $table) {
$table->dropPrimary();
$table->primary(['id','site_id']);
$table->date('connect_at')->nullable()->after('contract_term');
$table->date('expire_at')->nullable()->after('connect_at');
$table->ipAddress('ip6address')->nullable()->after('ipaddress');
$table->string('technology')->nullable();
$table->dropForeign('ab_service__adsl_site_id_foreign');
$table->dropIndex('ab_service__adsl_site_id_foreign');
$table->dropIndex('ab_service__adsl_id_site_id_index');
$table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services');
$table->foreign(['provided_supplier_broadband_id','site_id'])->references(['id','site_id'])->on('supplier_broadband');
});
// Convert our dates
foreach (\App\Models\Service\Broadband::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)->cursor() as $o) {
if ($o->service_connect_date)
$o->connect_at = \Carbon\Carbon::createFromTimestamp($o->service_connect_date);
if ($o->getRawOriginal('contract_term') === 0)
$o->contract_term = NULL;
if ($o->service_contract_date && $o->getRawOriginal('contract_term'))
$o->expire_at = \Carbon\Carbon::createFromTimestamp($o->service_contract_date)->addMonths($o->getRawOriginal('contract_term'));
$o->save();
}
Schema::table('service_broadband', function (Blueprint $table) {
$table->dropColumn(['service_connect_date','service_contract_date','contract_term']);
});
Schema::table('supplier_broadband', function (Blueprint $table) {
$table->string('technology')->nullable();
});
DB::select("UPDATE services SET model='App\\\\Models\\\\Service\\\\Phone' where model='App\\\\Models\\\\Service\\\\Voip'");
DB::select("UPDATE products SET model='App\\\\Models\\\\Product\\\\Phone' where model='App\\\\Models\\\\Product\\\\Voip'");
DB::statement('ALTER TABLE ab_service__ssl RENAME TO service_ssl');
DB::statement('ALTER TABLE service_ssl MODIFY service_id int unsigned NOT NULL');
DB::statement('ALTER TABLE service_ssl MODIFY ssl_ca_id int unsigned DEFAULT NULL');
Schema::table('service_ssl', function (Blueprint $table) {
$table->dropPrimary();
$table->primary(['id','site_id']);
$table->dropForeign('ab_service__ssl_site_id_foreign');
$table->dropIndex('ab_service__ssl_site_id_foreign');
$table->dropIndex('ab_service__ssl_id_site_id_index');
$table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services');
});
foreach (DB::select('SELECT * FROM products where model="App\\\\Models\\\\Product\\\\SSL"') as $o) {
DB::select('UPDATE services set model="App\\\\Models\\\\Service\\\\SSL" WHERE product_id='.$o->id);
};
Schema::table('products', function (Blueprint $table) {
$table->dropForeign(['site_id']);
$table->foreign(['site_id'])->references(['site_id'])->on('sites');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
abort(500,'Cant go back');
}
}

View File

@ -1,42 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class RenameTraffic extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
DB::statement('ALTER TABLE ab_service__adsl_traffic RENAME TO usage_broadband');
DB::statement('ALTER TABLE usage_broadband RENAME COLUMN ab_service_adsl_id TO service_item_id');
DB::statement('ALTER TABLE usage_broadband MODIFY supplier_id int unsigned NOT NULL'); // @todo This should be deleted, it could be obtained by the product
DB::statement('ALTER TABLE usage_broadband MODIFY service_item_id int unsigned DEFAULT NULL');
DB::statement('ALTER TABLE usage_broadband MODIFY site_id int unsigned NOT NULL');
Schema::table('usage_broadband', function (Blueprint $table) {
$table->unique(['service_item_id','site_id','date','time']);
$table->foreign(['service_item_id','site_id'])->references(['id','site_id'])->on('service_broadband');
$table->foreign(['supplier_id'])->references(['id'])->on('suppliers');
});
Schema::table('suppliers', function (Blueprint $table) {
$table->date('usage_last')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
abort(500,'Cant go back');
}
}

View File

@ -1,48 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('accounts', function (Blueprint $table) {
$table->datetime('created_at')->nullable()->after('id');
$table->datetime('updated_at')->nullable()->after('created_at');
$table->date('expire_at')->nullable()->after('updated_at');
});
// Convert our dates
foreach (\App\Models\Account::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)->cursor() as $o) {
if ($o->date_orig)
$o->created_at = \Carbon\Carbon::createFromTimestamp($o->date_orig);
if ($o->date_last)
$o->updated_at = \Carbon\Carbon::createFromTimestamp($o->date_last);
if ($o->date_expire)
$o->expire_at = \Carbon\Carbon::createFromTimestamp($o->date_expire);
$o->save();
}
Schema::table('accounts', function (Blueprint $table) {
$table->dropColumn(['date_orig','date_last','date_expire']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
abort(500,'Cant go back');
}
};

View File

@ -1,124 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
DB::statement('ALTER TABLE ab_invoice RENAME TO invoices');
DB::statement('ALTER TABLE invoices MODIFY account_id int unsigned NOT NULL');
DB::statement('ALTER TABLE invoices MODIFY account_billing_id int unsigned DEFAULT NULL');
DB::statement('ALTER TABLE invoices MODIFY active tinyint(1) NOT NULL,MODIFY process_status tinyint(1) DEFAULT NULL,MODIFY billing_status tinyint(1) DEFAULT NULL,MODIFY print_status tinyint(1) DEFAULT NULL');
Schema::table('invoices', function (Blueprint $table) {
$table->dropPrimary();
$table->dropForeign('ab_invoice_site_id_foreign');
$table->dropIndex('ab_invoice_site_id_foreign');
$table->primary(['id','site_id']);
$table->dropIndex('ab_invoice_id_site_id_index');
$table->datetime('created_at')->nullable()->after('id');
$table->datetime('updated_at')->nullable()->after('created_at');
$table->date('due_at')->nullable()->after('discount_amt');
});
// Convert out dates
foreach (\App\Models\Invoice::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)->cursor() as $o) {
if ($o->date_orig)
$o->created_at = \Carbon\Carbon::createFromTimestamp($o->date_orig);
if ($o->date_last)
$o->updated_at = \Carbon\Carbon::createFromTimestamp($o->date_last);
if ($o->getRawOriginal('due_date'))
$o->due_at = \Carbon\Carbon::createFromTimestamp($o->getRawOriginal('due_date'));
if ($o->reminders) {
try {
$reminders = unserialize($o->reminders);
} catch (Exception $e) {
$reminders = unserialize(gzuncompress($o->reminders));
}
$o->reminders = $reminders;
}
$o->save();
}
Schema::table('invoices', function (Blueprint $table) {
$table->dropColumn(['date_orig','date_last','due_date']);
$table->foreign(['account_id','site_id'])->references(['id','site_id'])->on('accounts');
});
DB::statement('ALTER TABLE ab_invoice_item RENAME TO invoice_items');
DB::statement('ALTER TABLE invoice_items MODIFY invoice_id int unsigned NOT NULL');
DB::statement('ALTER TABLE invoice_items MODIFY service_id int unsigned DEFAULT NULL');
DB::statement('ALTER TABLE invoice_items MODIFY product_id int unsigned DEFAULT NULL');
DB::statement('ALTER TABLE invoice_items MODIFY module_id int unsigned DEFAULT NULL');
DB::statement('ALTER TABLE invoice_items MODIFY module_ref int unsigned DEFAULT NULL');
DB::statement('ALTER TABLE invoice_items RENAME COLUMN recurring_schedule TO recur_schedule');
Schema::table('invoice_items', function (Blueprint $table) {
$table->dropPrimary();
$table->dropForeign('ab_invoice_item_site_id_foreign');
$table->dropIndex('ab_invoice_item_site_id_foreign');
$table->primary(['id','site_id']);
$table->dropIndex('ab_invoice_item_id_site_id_index');
$table->datetime('created_at')->nullable()->after('id');
$table->datetime('updated_at')->nullable()->after('created_at');
$table->date('start_at')->nullable()->after('recur_schedule');
$table->date('stop_at')->nullable()->after('start_at');
});
// Convert out dates
foreach (\App\Models\InvoiceItem::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)->cursor() as $o) {
if ($o->date_orig)
$o->created_at = \Carbon\Carbon::createFromTimestamp($o->date_orig);
if ($o->date_last)
$o->updated_at = \Carbon\Carbon::createFromTimestamp($o->date_last);
if ($o->date_start)
$o->start_at = \Carbon\Carbon::createFromTimestamp($o->date_start);
if ($o->date_stop)
$o->stop_at = \Carbon\Carbon::createFromTimestamp($o->date_stop);
$o->save();
}
Schema::table('invoice_items', function (Blueprint $table) {
$table->dropColumn(['date_orig','date_last','date_start','date_stop']);
$table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services');
$table->foreign(['invoice_id','site_id'])->references(['id','site_id'])->on('invoices');
$table->foreign(['product_id','site_id'])->references(['id','site_id'])->on('products');
});
DB::statement('ALTER TABLE ab_invoice_item_tax RENAME TO invoice_item_taxes');
DB::statement('ALTER TABLE invoice_item_taxes MODIFY invoice_item_id int unsigned NOT NULL');
DB::statement('ALTER TABLE invoice_item_taxes MODIFY tax_id int unsigned NOT NULL');
DB::statement('ALTER TABLE invoice_item_taxes DROP PRIMARY KEY,ADD PRIMARY KEY (id,site_id)');
Schema::table('invoice_item_taxes', function (Blueprint $table) {
$table->dropForeign('ab_invoice_item_tax_site_id_foreign');
$table->dropIndex('ab_invoice_item_tax_site_id_foreign');
$table->dropIndex('ab_invoice_item_tax_id_site_id_index');
$table->dropColumn(['date_orig']);
$table->foreign(['invoice_item_id','site_id'])->references(['id','site_id'])->on('invoice_items');
$table->foreign(['tax_id'])->references(['id'])->on('taxes');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
abort(500,'Cant go back');
}
};

View File

@ -1,71 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
DB::statement('ALTER TABLE payments MODIFY account_id int unsigned NOT NULL');
DB::statement('ALTER TABLE payments MODIFY checkout_id int unsigned NOT NULL');
DB::statement('ALTER TABLE payments MODIFY source_id int unsigned DEFAULT NULL');
DB::statement('ALTER TABLE payments MODIFY pending_status tinyint(1) DEFAULT NULL');
Schema::table('payments', function (Blueprint $table) {
$table->dropForeign(['site_id']);
$table->datetime('created_at')->nullable()->after('id');
$table->datetime('updated_at')->nullable()->after('created_at');
$table->boolean('active')->nullable()->after('updated_at');
$table->date('paid_at')->nullable()->after('payment_date');
$table->foreign(['account_id','site_id'])->references(['id','site_id'])->on('accounts');
$table->foreign(['source_id','site_id'])->references(['id','site_id'])->on('users');
});
// Convert out dates
foreach (\App\Models\Payment::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)->cursor() as $o) {
if ($o->date_orig)
$o->created_at = \Carbon\Carbon::createFromTimestamp($o->date_orig);
if ($o->date_last)
$o->updated_at = \Carbon\Carbon::createFromTimestamp($o->date_last);
if ($o->payment_date)
$o->paid_at = \Carbon\Carbon::createFromTimestamp($o->payment_date);
$o->save();
}
Schema::table('payments', function (Blueprint $table) {
$table->dropColumn(['date_orig','date_last','payment_date']);
});
DB::statement('ALTER TABLE payment_items MODIFY payment_id int unsigned NOT NULL');
DB::statement('ALTER TABLE payment_items MODIFY invoice_id int unsigned DEFAULT NULL');
DB::statement('ALTER TABLE payment_items RENAME COLUMN alloc_amt TO amount');
Schema::table('payment_items', function (Blueprint $table) {
$table->dropForeign(['site_id']);
$table->boolean('active')->nullable()->after('site_id');
$table->dropColumn(['date_orig','date_last']);
$table->foreign(['payment_id','site_id'])->references(['id','site_id'])->on('payments');
});
DB::statement('UPDATE payment_items SET active=1');
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
abort(500,'Cant go back');
}
};

Some files were not shown because too many files have changed in this diff Show More