<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateAttributesTable extends Migration
{
    public function up()
    {
        Schema::create('policies', function(Blueprint $table)
        {
            $table->increments('id')->unsigned();
            $table->string('title', 255);
            $table->string('description')->nullable();

            // Password history. NULL means no password history.
            // An integer value means how many passwords must be recycled before old one can be used
            $table->integer('history')->nullable();

            // Minimum password length. NULL means no limit
            $table->integer('min_length')->nullable()->default('8');

            // Minimum password strength, according to ZXCVBN strength-meter
            $table->integer('min_strength')->nullable()->default('1');

            // How many BAD auth. attempts are required before account is locked out. NULL for unlimited
            $table->integer('lockout')->nullable()->default('3');

            // How many seconds to be locked for until authentication is allowed again
            $table->integer('lockout_duration')->unsigned()->default('0');

            // How many days the password is valid for, before user is required to change it.
            // NULL to turn it off.
            $table->integer('max_age')->nullable()->default('180');

            $table->timestamps();
        });
    }

    public function down()
    {
        Schema::disableForeignKeyConstraints();
        Schema::dropIfExists('policies');
    }
}