Entrypoint to migrate the schema.
    For the moment only create tables.
483962
def migrate(module=None):
    
    if not module:
        #Parsing
        parser = argparse.ArgumentParser()
        parser.add_argument('-s', '--service', type=str, help='Migrate the module', required=True,
                            dest='module')
        args = parser.parse_args()
        module = args.module
    #1. Load settings
    farine.settings.load()
    #2. Load the module
    models = farine.discovery.import_models(module)
    #3. Get the connection
    db = farine.connectors.sql.setup(getattr(farine.settings, module))
    #4. Create tables
    for model in models:
        model._meta.database = db
        model.create_table(fail_silently=True)
1346601
public function migrate()
	{
		$schema = $this->getSchema( 'db-customer' );
		$sql = 'SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = \'users\' AND COLUMN_NAME = \'id\'';

		try {
			$type = $this->getValue( $sql, 'COLUMN_TYPE', 'db-customer' );
		} catch( \Aimeos\MW\Setup\Exception $e ) {
			$type = null;
		}

		if( in_array( $type, ['int(10)', 'int(11)'] ) )
		{
			$this->msg( sprintf( 'Remove signed constraints in users related tables' ), 0 );
			$this->status( '' );


			$this->msg( 'Checking constraint in "users_address"', 1 );

			if( $schema->constraintExists( 'users_address', 'fk_lvuad_pid' ) )
			{
				$this->execute( 'ALTER TABLE "users_address" DROP FOREIGN KEY "fk_lvuad_pid"', 'db-customer' );
				$this->status( 'done' );
			}
			else
			{
				$this->status( 'OK' );
			}


			$this->msg( 'Checking constraint in "users_list"', 1 );

			if( $schema->constraintExists( 'users_list', 'fk_lvuli_pid' ) )
			{
				$this->execute( 'ALTER TABLE "users_list" DROP FOREIGN KEY "fk_lvuli_pid"', 'db-customer' );
				$this->status( 'done' );
			}
			else
			{
				$this->status( 'OK' );
			}


			$this->msg( 'Checking constraint in "users_property"', 1 );

			if( $schema->constraintExists( 'users_property', 'fk_lvupr_pid' ) )
			{
				$this->execute( 'ALTER TABLE "users_property" DROP FOREIGN KEY "fk_lvupr_pid"', 'db-customer' );
				$this->status( 'done' );
			}
			else
			{
				$this->status( 'OK' );
			}
		}
	}
56362
public function createRepository()
    {
        $schema = $this->connection->getSchemaBuilder();

        $schema->create($this->table, function ($table) {
            $table->string('migration');
            $table->string('extension')->nullable();
        });
    }
301011
public function up()
    {
        Schema::create('translator_translations', function ($table) {
            $table->increments('id');
            $table->string('locale', 6);
            $table->string('namespace')->default('*');
            $table->string('group');
            $table->string('item');
            $table->text('text');
            $table->boolean('unstable')->default(false);
            $table->boolean('locked')->default(false);
            $table->timestamps();
            $table->foreign('locale')->references('locale')->on('translator_languages');
            $table->unique(['locale', 'namespace', 'group', 'item']);
        });
    }
416719
def setup_migrate(app):
    """"""
    directory = path.join(path.dirname(__file__), 'migrations')
    migrate.init_app(app, db, directory=directory)
1254820
def migrate(ctx, start_version, end_version):
    """"""
    if ctx.type == 'file':
        if ctx.data_file:
            file_path = ctx.data_file
        else:
            file_path = os.path.join(ctx.data_file, ctx.namespace + '.json')

        # todo make this more like alemebic and determine/load versions automatically
        with open(file_path, 'r') as f:
            data = json.loads(f.read())

        data = run_migration(data, start_version, end_version)
        with open(file_path, 'w') as f:
            f.write(json.dumps(data))
1353512
public function up()
    {
        Schema::create('scaffoldinterfaces', function (Blueprint $table) {
            $table->increments('id');
            $table->String('package');
            $table->String('migration');
            $table->String('model');
            $table->String('controller');
            $table->String('views');
            $table->String('tablename');
            $table->timestamps();
        });
    }
559228
protected function createMigration()
    {
        $table = $this->option('pivot') ?
            Str::snake(class_basename($this->argument('name'))) :
            Str::plural(Str::snake(class_basename($this->argument('name'))));

        $this->call('make:migration', [
            'name' => "create_{$table}_table",
            '--create' => $table,
        ]);
    }
945587
public function migrate()
	{
		$table = 'fe_users';
		$column = 'siteid';

		$this->msg( sprintf( 'Adding "%1$s" column to "%2$s" table', $column, $table ), 0 );

		$schema = $this->getSchema( 'db-customer' );

		if( isset( $this->migrate[$schema->getName()] )
			&& $schema->tableExists( $table ) === true
			&& $schema->columnExists( $table, $column ) === false )
		{
			foreach ( $this->migrate[$schema->getName()] as $stmt )
			{
				$this->execute( $stmt );
			}
			$this->status( 'done' );
		}
		else
		{
			$this->status( 'OK' );
		}
	}
464236
def create_schema(self, check_if_exists=False, sync_schema=True,
                      verbosity=1):
        

        # safety check
        _check_schema_name(self.schema_name)
        cursor = connection.cursor()

        if check_if_exists and schema_exists(self.schema_name):
            return False

        # create the schema
        cursor.execute('CREATE SCHEMA %s' % self.schema_name)

        if sync_schema:
            call_command('migrate_schemas',
                         schema_name=self.schema_name,
                         interactive=False,
                         verbosity=verbosity)

        connection.set_schema_to_public()
1346427
public function up()
    {
        $driver = Schema::getConnection()->getDriverName();
        // Even though we take care of this scenario in the code,
        // SQL Server does not allow potential cascading loops,
        // so set the default no action and clear out created/modified by another user when deleting a user.
        $onDelete = (('sqlsrv' === $driver) ? 'no action' : 'set null');

        $output = new ConsoleOutput();
        $output->writeln("Migration driver used: $driver");

        // Script Service Config
        if (!Schema::hasTable('script_config')) {
            Schema::create(
                'script_config',
                function (Blueprint $t) {
                    $t->integer('service_id')->unsigned()->primary();
                    $t->foreign('service_id')->references('id')->on('service')->onDelete('cascade');
                    $t->mediumText('content')->nullable();
                    $t->text('config')->nullable();
                }
            );
        }

        // Event Scripts
        if (!Schema::hasTable('event_script')) {
            Schema::create(
                'event_script',
                function (Blueprint $t) use ($onDelete) {
                    $t->string('name', 80)->primary();
                    $t->string('type', 40);
                    $t->boolean('is_active')->default(0);
                    $t->mediumText('content')->nullable();
                    $t->text('config')->nullable();
                    $t->timestamp('created_date')->nullable();
                    $t->timestamp('last_modified_date')->useCurrent();
                    $t->integer('created_by_id')->unsigned()->nullable();
                    $t->foreign('created_by_id')->references('id')->on('user')->onDelete($onDelete);
                    $t->integer('last_modified_by_id')->unsigned()->nullable();
                    $t->foreign('last_modified_by_id')->references('id')->on('user')->onDelete($onDelete);
                }
            );
        }
    }
1335057
public function migrateUp()
    {
        $this->builder->create(
            $this->table,
            function ($table) {
                $table->bigIncrements('id');

                $table->string('sha1', 40)->index();
                $table->text('statement');
                $table->double('time')->index();
                $table->integer('connection_id')->unsigned();

                $table->timestamps();
                $table->index('created_at');
                $table->index('updated_at');
            }
        );
    }
1288956
public function up()
    {
        // Create table for storing roles
        Schema::create('data_types', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name')->unique();
            $table->string('slug')->unique();
            $table->string('display_name_singular');
            $table->string('display_name_plural');
            $table->string('icon')->nullable();
            $table->string('model_name')->nullable();
            $table->string('description')->nullable();
            $table->boolean('generate_permissions')->default(false);
            $table->timestamps();
        });

        // Create table for storing roles
        Schema::create('data_rows', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('data_type_id')->unsigned();
            $table->string('field');
            $table->string('type');
            $table->string('display_name')->nullable();
            $table->boolean('required')->default(false);
            $table->boolean('browse')->default(true);
            $table->boolean('read')->default(true);
            $table->boolean('edit')->default(true);
            $table->boolean('add')->default(true);
            $table->boolean('delete')->default(true);
            $table->text('details')->nullable();

            $table->foreign('data_type_id')->references('id')->on('data_types')
                ->onUpdate('cascade')->onDelete('cascade');
        });
    }
827429
public function up()
    {
        Schema::create('languages', function(Blueprint $table) {
            $table->increments('id');
            $table->string('name')->nullable()->default(null);
            $table->string('code')->nullable()->default(null);
            $table->tinyInteger('is_default')->default(0);
            $table->timestamps();
        });

        Schema::create('categories', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('parent_id')->nullable()->default(null);
            $table->string('name');
            $table->string('slug');
            $table->string('meta_title')->nullable()->default(null);
            $table->string('meta_description')->nullable()->default(null);

            $table->timestamps();
        });

        Schema::create('category_filters', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('category_id')->unsigned()->nullable()->default(null);
            $table->enum('type', ['ATTRIBUTE', 'PROPERTY'])->nullable()->default(null);
            $table->integer('filter_id');
            $table->timestamps();

            $table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');
        });

        Schema::create('products', function(Blueprint $table) {
            $table->increments('id');
            $table->enum('type', ['BASIC', 'VARIATION', 'DOWNLOADABLE', 'VARIABLE_PRODUCT'])->default('BASIC');

            $table->string('name')->nullable()->default(null);
            $table->string('slug')->nullable()->default(null);
            $table->string('sku')->nullable()->default(null);
            $table->text('description')->nullable()->default(null);
            $table->tinyInteger('status')->nullable()->default(null);
            $table->tinyInteger('in_stock')->nullable()->default(null);
            $table->tinyInteger('track_stock')->nullable()->default(null);
            $table->decimal('qty', 10, 6)->nullable();
            $table->tinyInteger('is_taxable')->nullable()->default(null);
            $table->decimal('price', 10, 6)->nullable()->default(null);
            $table->decimal('cost_price', 10, 6)->nullable()->default(null);

            $table->float('weight')->nullable()->default(null);
            $table->float('width')->nullable()->default(null);
            $table->float('height')->nullable()->default(null);
            $table->float('length')->nullable()->default(null);

            $table->string('meta_title')->nullable()->default(null);
            $table->string('meta_description')->nullable()->default(null);
            $table->timestamps();
        });

        Schema::create('category_product', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('category_id')->unsigned();
            $table->integer('product_id')->unsigned();
            $table->timestamps();

            $table->foreign('product_id')->references('id')->on('products')->onDelete('cascade');
            $table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');
        });

        Schema::create('product_downloadable_urls', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('product_id')->unsigned();
            $table->string('demo_path')->nullable()->default(null);
            $table->string('main_path')->nullable()->default(null);
            $table->string('token');
            $table->timestamps();

            $table->foreign('product_id')->references('id')->on('products')->onDelete('cascade');
        });

        Schema::create('product_images', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('product_id')->unsigned();
            $table->text('path');
            $table->boolean('is_main_image')->nullable()->default(null);
            $table->timestamps();

            $table->foreign('product_id')->references('id')->on('products')->onDelete('cascade');
        });

        Schema::create('order_statuses', function(Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->tinyInteger('is_default')->default(0);
            $table->timestamps();
        });

        OrderStatus::insert([
            ['name' => 'New', 'is_default' => 1],
            ['name' => 'Pending Payment', 'is_default' => 0],
            ['name' => 'Processing', 'is_default' => 0],
            ['name' => 'Shipped', 'is_default' => 0],
            ['name' => 'Delivered', 'is_default' => 0],
            ['name' => 'Canceled', 'is_default' => 0],
        ]);

        Schema::create('orders', function(Blueprint $table) {
            $table->increments('id');

            $table->string('shipping_option');
            $table->string('payment_option');
            $table->integer('order_status_id')->unsigned();
            $table->string('currency_code')->nullable()->default(null);
            $table->timestamps();

            $table->foreign('order_status_id')->references('id')->on('order_statuses');
        });

        Schema::create('order_histories', function(Blueprint $table) {
            $table->increments('id');

            $table->integer('order_id')->unsigned()->nullable()->default(null);
            $table->integer('order_status_id')->unsigned()->nullable()->default(null);

            $table->timestamps();

            $table->foreign('order_status_id')->references('id')->on('order_statuses');
            $table->foreign('order_id')->references('id')->on('orders');
        });

        Schema::create('order_product', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('product_id')->unsigned();
            $table->integer('order_id')->unsigned();
            $table->integer('qty');
            $table->decimal('price', 11, 6);
            $table->decimal('tax_amount', 11, 6);
            $table->json('product_info')->nullable()->default(null);
            $table->timestamps();

            $table->foreign('order_id')->references('id')->on('orders');
            $table->foreign('product_id')->references('id')->on('products')->onDelete('cascade');
        });

        Schema::create('order_return_requests', function(Blueprint $table) {
            $table->increments('id');

            $table->integer('order_id')->unsigned()->nullable()->default(null);
            $table->foreign('order_id')->references('id')->on('orders')->onDelete('cascade');

            $table->enum('status', ['PENDING', 'IN_PROGRESSS', 'APPROVED', 'REJECTED'])->nullable()->default(null);
            $table->text('comment')->nullable()->default(null);

            $table->timestamps();
        });

        Schema::create('order_return_products', function(Blueprint $table) {
            $table->increments('id');

            $table->integer('order_return_request_id')->unsigned()->nullable()->default(null);
            $table->foreign('order_return_request_id')->references('id')->on('order_return_requests')->onDelete('cascade');

            $table->integer('product_id')->unsigned()->nullable()->default(null);
            $table->foreign('product_id')->references('id')->on('products')->onDelete('cascade');

            $table->integer('qty');
            $table->text('reason')->nullable()->default(null);
            $table->timestamps();
        });

        Schema::create('properties', function(Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('identifier')->unique();
            $table->enum('data_type', ['INTEGER', 'DECIMAL', 'DATETIME', 'VARCHAR', 'BOOLEAN', 'TEXT'])->nullable()->default(null);
            $table->enum('field_type', ['TEXT', 'TEXTAREA', 'CKEDITOR', 'SELECT', 'FILE', 'DATETIME', 'CHECKBOX', 'RADIO', 'SWITCH']);
            $table->tinyInteger('use_for_all_products')->default(0);
            $table->tinyInteger('is_visible_frontend')->nullable()->default(1);
            $table->integer('sort_order')->nullable()->default(0);
            $table->timestamps();
        });

        Schema::create('property_dropdown_options', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('property_id')->unsigned();
            $table->string('display_text');
            $table->timestamps();
            $table->foreign('property_id')
                ->references('id')->on('properties')->onDelete('cascade');
        });

        Schema::create('product_property', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('property_id')->unsigned();
            $table->integer('product_id')->unsigned();

            $table->timestamps();

            $table->foreign('property_id')
                ->references('id')->on('properties')->onDelete('cascade');
            $table->foreign('product_id')
                ->references('id')->on('products')->onDelete('cascade');
        });
        Schema::create('product_property_varchar_values', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('property_id')->unsigned();
            $table->integer('product_id')->unsigned();
            $table->string('value')->nullable()->default(null);
            $table->timestamps();

            $table->foreign('property_id')
                ->references('id')->on('properties')->onDelete('cascade');
            $table->foreign('product_id')
                ->references('id')->on('products')->onDelete('cascade');
        });

        Schema::create('product_property_datetime_values', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('property_id')->unsigned();
            $table->integer('product_id')->unsigned();
            $table->timestamp('value')->nullable()->default(null);
            $table->timestamps();

            $table->foreign('property_id')
                ->references('id')->on('properties')->onDelete('cascade');
            $table->foreign('product_id')
                ->references('id')->on('products')->onDelete('cascade');
        });

        Schema::create('product_property_integer_values', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('property_id')->unsigned();
            $table->integer('product_id')->unsigned();
            $table->integer('value')->nullable()->default(null);
            $table->timestamps();

            $table->foreign('property_id')
                ->references('id')->on('properties')->onDelete('cascade');
            $table->foreign('product_id')
                ->references('id')->on('products')->onDelete('cascade');
        });

        Schema::create('product_property_decimal_values', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('property_id')->unsigned();
            $table->integer('product_id')->unsigned();
            $table->decimal('value')->nullable()->default(null);
            $table->timestamps();

            $table->foreign('property_id')
                ->references('id')->on('properties')->onDelete('cascade');
            $table->foreign('product_id')
                ->references('id')->on('products')->onDelete('cascade');
        });

        Schema::create('product_property_text_values', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('property_id')->unsigned();
            $table->integer('product_id')->unsigned();
            $table->text('value')->nullable()->default(null);
            $table->timestamps();

            $table->foreign('property_id')
                ->references('id')->on('properties')->onDelete('cascade');
            $table->foreign('product_id')
                ->references('id')->on('products')->onDelete('cascade');
        });

        Schema::create('product_property_boolean_values', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('property_id')->unsigned();
            $table->integer('product_id')->unsigned();
            $table->tinyInteger('value')->nullable()->default(null);
            $table->timestamps();

            $table->foreign('property_id')
                ->references('id')->on('properties')->onDelete('cascade');
            $table->foreign('product_id')
                ->references('id')->on('products')->onDelete('cascade');
        });

        Schema::create('attributes', function(Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('identifier')->unique();
            $table->timestamps();
        });

        Schema::create('attribute_product', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('attribute_id')->unsigned();
            $table->integer('product_id')->unsigned();
            $table->timestamps();

            $table->foreign('attribute_id')
                ->references('id')->on('attributes')->onDelete('cascade');
            $table->foreign('product_id')
                ->references('id')->on('products')->onDelete('cascade');
        });

        Schema::create('attribute_dropdown_options', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('attribute_id')->unsigned();
            $table->string('display_text');
            $table->timestamps();
            $table->foreign('attribute_id')
                ->references('id')->on('attributes')->onDelete('cascade');
        });

        Schema::create('product_attribute_integer_values', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('attribute_id')->unsigned();
            $table->integer('product_id')->unsigned();
            $table->integer('value')->nullable()->default(null);
            $table->timestamps();

            $table->foreign('attribute_id')
                ->references('id')->on('attributes')->onDelete('cascade');
            $table->foreign('product_id')
                ->references('id')->on('products')->onDelete('cascade');
        });

        Schema::create('product_variations', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('variation_id')->unsigned();
            $table->integer('product_id')->unsigned();
            $table->timestamps();

            $table->foreign('variation_id')
                ->references('id')->on('products')->onDelete('cascade');
            $table->foreign('product_id')
                ->references('id')->on('products')->onDelete('cascade');
        });

        Schema::create('order_product_variations', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('order_id')->unsigned();
            $table->integer('product_id')->unsigned();
            $table->integer('attribute_id')->unsigned();
            $table->integer('attribute_dropdown_option_id')->unsigned()->nullable()->default(null);
            $table->timestamps();

            $table->foreign('order_id')->references('id')->on('orders');
            $table->foreign('product_id')->references('id')->on('products')->onDelete('cascade');
            ;
            $table->foreign('attribute_id')->references('id')->on('attributes');
            $table->foreign('attribute_dropdown_option_id')->references('id')->on('attribute_dropdown_options');
        });

        Schema::create('configurations', function(Blueprint $table) {
            $table->increments('id');
            $table->string('configuration_key')->nullable()->default(null);
            $table->string('configuration_value', 999)->nullable()->default(null);
            $table->timestamps();
        });

        Schema::create('admin_password_resets', function(Blueprint $table) {
            $table->string('email')->index();
            $table->string('token')->index();
            $table->timestamp('created_at');
        });

        Schema::create('password_resets', function(Blueprint $table) {
            $table->string('email')->index();
            $table->string('token')->index();
            $table->timestamp('created_at');
        });

        Schema::create('roles', function(Blueprint $table) {
            $table->increments('id');
            $table->string('name')->nullable()->default(null);
            $table->text('description')->nullable()->default(null);
            $table->timestamps();
        });

        Schema::create('admin_users', function(Blueprint $table) {
            $table->increments('id');
            $table->tinyInteger('is_super_admin')->nullable()->default(null);
            $table->integer('role_id')->unsigned()->default(null);
            $table->string('first_name')->nullable();
            $table->string('last_name')->nullable();
            $table->string('email')->unique();
            $table->string('password');
            $table->string('language')->nullable()->default('en');
            $table->string('image_path')->nullable()->default(null);
            $table->rememberToken();
            $table->timestamp('email_verified_at')->nullable();
            $table->timestamps();

            $table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade');
        });

        Schema::create('users', function(Blueprint $table) {
            $table->increments('id');
            $table->string('first_name')->nullable()->default(null);
            $table->string('last_name')->nullable()->default(null);
            $table->string('email')->unique();
            $table->string('password');
            $table->string('image_path')->nullable();
            $table->string('company_name')->nullable();
            $table->string('phone')->nullable();
            $table->enum('status', ['GUEST', 'LIVE', 'DELETE_IN_PROGRESS'])->default('LIVE');
            $table->string('tax_no')->nullable()->default(null);
            $table->timestamp('email_verified_at')->nullable();
            $table->timestamp('delete_due_date')->nullable()->default(null);
            $table->enum('registered_channel', ['WEBSITE', 'FACEBOOK', 'TWITTER', 'GOOGLE'])->default('WEBSITE');
            $table->rememberToken();
            $table->timestamps();
            $table->softDeletes();
                
        });

        Schema::create('user_groups', function(Blueprint $table) {
            $table->increments('id');
            $table->string('name')->nullable()->default(null);
            $table->tinyInteger('is_default')->default(0);
            $table->timestamps();
        });

        Schema::create('user_user_group', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->unsigned();
            $table->integer('user_group_id')->unsigned();
            $table->timestamps();

            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
            $table->foreign('user_group_id')->references('id')->on('user_groups')->onDelete('cascade');
        });

        Schema::create('countries', function(Blueprint $table) {
            $table->increments('id');
            $table->string('code');
            $table->string('name');
            $table->string('phone_code')->nullable()->default(null);
            $table->string('currency_code')->nullable()->default(null);
            $table->string('currency_symbol')->nullable()->default(null);
            $table->string('lang_code')->nullable()->default(null);
            $table->timestamps();
        });

        Schema::create('site_currencies', function(Blueprint $table) {
            $table->increments('id');
            $table->string('code');
            $table->string('symbol');
            $table->string('name');
            $table->float('conversion_rate');
            $table->enum('status', ['ENABLED', 'DISABLED'])->nullable()->default(null);
            $table->timestamps();
        });

        Schema::create('addresses', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->unsigned();
            $table->enum('type', ['SHIPPING', 'BILLING']);
            $table->string('first_name')->nullable()->default(null);
            $table->string('last_name')->nullable()->default(null);
            $table->string('address1')->nullable()->default(null);
            $table->string('address2')->nullable()->default(null);
            $table->string('postcode')->nullable()->default(null);
            $table->string('city')->nullable()->default(null);
            $table->string('state')->nullable()->default(null);
            $table->integer('country_id')->unsigned()->nullable()->default(null);
            $table->string('phone')->nullable()->default(null);
            $table->timestamps();

            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
            $table->foreign('country_id')->references('id')->on('countries')->onDelete('cascade');
        });

        Schema::create('oauth_auth_codes', function(Blueprint $table) {
            $table->string('id', 100)->primary();
            $table->integer('user_id');
            $table->integer('client_id');
            $table->text('scopes')->nullable();
            $table->boolean('revoked');
            $table->dateTime('expires_at')->nullable();
        });

        Schema::create('oauth_access_tokens', function(Blueprint $table) {
            $table->string('id', 100)->primary();
            $table->integer('user_id')->index()->nullable();
            $table->integer('client_id');
            $table->string('name')->nullable();
            $table->text('scopes')->nullable();
            $table->boolean('revoked');
            $table->timestamps();
            $table->dateTime('expires_at')->nullable();
        });

        Schema::create('oauth_refresh_tokens', function(Blueprint $table) {
            $table->string('id', 100)->primary();
            $table->string('access_token_id', 100)->index();
            $table->boolean('revoked');
            $table->dateTime('expires_at')->nullable();
        });

        Schema::create('oauth_clients', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->index()->nullable();
            $table->string('name');
            $table->string('secret', 100);
            $table->text('redirect');
            $table->boolean('personal_access_client');
            $table->boolean('password_client');
            $table->boolean('revoked');
            $table->timestamps();
        });

        Schema::create('oauth_personal_access_clients', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('client_id')->index();
            $table->timestamps();
        });

        Schema::create('pages', function(Blueprint $table) {
            $table->increments('id');
            $table->string('name')->nullable()->default(null);
            $table->string('slug')->nullable()->default(null);
            $table->text('content')->nullable()->default(null);
            $table->string('meta_title')->nullable();
            $table->string('meta_description')->nullable();
            $table->timestamps();
        });

        Schema::create('wishlists', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->unsigned();
            $table->integer('product_id')->unsigned();
            $table->timestamps();

            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
            $table->foreign('product_id')->references('id')->on('products')->onDelete('cascade');
        });

        Schema::create('permissions', function(Blueprint $table) {
            $table->increments('id');
            $table->string('name')->unique();
            $table->timestamps();
        });

        Schema::create('permission_role', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('permission_id')->unsigned();
            $table->integer('role_id')->unsigned();
            $table->timestamps();

            $table->foreign('permission_id')->references('id')->on('permissions')->onDelete('cascade');
            $table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade');
        });

        Schema::create('states', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('country_id')->unsigned();
            $table->string('code');
            $table->string('name');
            $table->timestamps();

            $table->foreign('country_id')
                ->references('id')->on('countries')
                ->onDelete('cascade');
        });

        Schema::table('orders', function(Blueprint $table) {
            $table->integer('user_id')->unsigned()->nullable();
            $table->integer('shipping_address_id')->unsigned()->nullable();
            $table->integer('billing_address_id')->unsigned()->nullable();
            $table->string('track_code')->nullable()->default(null);

            $table->foreign('user_id')->references('id')->on('users');
            $table->foreign('shipping_address_id')->references('id')->on('addresses');
            $table->foreign('billing_address_id')->references('id')->on('addresses');
        });

        $path = __DIR__ . '/../../assets/countries.json';
        $json = json_decode(file_get_contents($path), true);
        foreach ($json as $country) {
            Country::create([
                'code' => strtolower(array_get($country, 'alpha2Code')),
                'name' => array_get($country, 'name'),
                'phone_code' => array_get($country, 'callingCodes.0'),
                'currency_code' => array_get($country, 'currencies.0.code'),
                'currency_symbol' => array_get($country, 'currencies.0.symbol'),
                'lang_code' => array_get($country, 'languages.0.name'),
            ]);
        }

        Schema::create('menu_groups', function(Blueprint $table) {
            $table->increments('id');
            $table->string('name')->nullable()->default(null);
            $table->string('identifier')->nullable()->default(null);
            $table->tinyInteger('is_default')->nullable()->default(0);
            $table->timestamps();
        });

        Schema::create('menus', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('menu_group_id')->unsigned();
            $table->integer('parent_id')->nullable()->default(null);
            $table->string('name')->nullable()->default(null);
            $table->string('route')->nullable()->default(null);
            $table->string('params')->nullable()->default(null);
            $table->integer('sort_order')->default(0);
            $table->timestamps();

            $table->foreign('menu_group_id')->references('id')->on('menu_groups')->onDelete('cascade');
        });

        Schema::create('tax_groups', function(Blueprint $table) {
            $table->increments('id');
            $table->string('name')->nullable()->default(null);
            $table->string('description')->nullable()->default(null);
            $table->timestamps();
        });

        Schema::create('tax_rates', function(Blueprint $table) {
            $table->increments('id');
            $table->string('name')->nullable()->default(null);
            $table->string('description')->nullable()->default(null);
            $table->float('rate', 10, 6);
            $table->integer('country_id')->unsigned();
            $table->integer('state_id')->unsigned()->nullable()->default(null);
            $table->integer('postcode')->nullable()->default(null);
            $table->enum('rate_type', ['PERCENTAGE', 'FIXED'])->default('PERCENTAGE');
            $table->enum('applied_with', ['SHIPPING', 'BILLING', 'STORE'])->default('SHIPPING');
            $table->timestamps();
        });


        Schema::create('category_translations', function(Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('category_id')->nullable()->default(null);
            $table->unsignedInteger('language_id')->nullable()->default(null);
            $table->string('name');
            $table->string('slug');
            $table->string('meta_title')->nullable()->default(null);
            $table->string('meta_description')->nullable()->default(null);

            $table->timestamps();

            $table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');
            $table->foreign('language_id')->references('id')->on('languages')->onDelete('cascade');
        });

        Schema::create('attribute_translations', function(Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('attribute_id')->nullable()->default(null);
            $table->unsignedInteger('language_id')->nullable()->default(null);
            $table->string('name')->nullable()->default(null);
            $table->string('identifier')->nullable()->default(null);
            $table->timestamps();

            $table->foreign('attribute_id')->references('id')->on('attributes')->onDelete('cascade');
            $table->foreign('language_id')->references('id')->on('languages')->onDelete('cascade');
        });

        Schema::create('attribute_dropdown_option_translations', function(Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('attribute_dropdown_option_id')->nullable()->default(null);
            $table->unsignedInteger('language_id')->nullable()->default(null);
            $table->string('display_text');
            $table->timestamps();

            $table->foreign('attribute_dropdown_option_id', 'adt')
                ->references('id')
                ->on('attribute_dropdown_options')
                ->onDelete('cascade');
            $table->foreign('language_id')->references('id')->on('languages')->onDelete('cascade');
        });

        Schema::create('property_translations', function(Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedInteger('property_id')->nullable()->default(null);
            $table->unsignedInteger('language_id')->nullable()->default(null);
            $table->string('name')->nullable()->default(null);
            $table->string('identifier')->unique()->nullable()->default(null);
            $table->timestamps();

            $table->foreign('property_id')->references('id')->on('properties')->onDelete('cascade');
            $table->foreign('language_id')->references('id')->on('languages')->onDelete('cascade');
        });

        Schema::create('property_dropdown_option_translations', function(Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('property_dropdown_option_id')->nullable()->default(null);
            $table->unsignedInteger('language_id')->nullable()->default(null);
            $table->string('display_text');
            $table->timestamps();

            $table->foreign('property_dropdown_option_id', 'pdt')
                ->references('id')
                ->on('property_dropdown_options')
                ->onDelete('cascade');
            $table->foreign('language_id')->references('id')->on('languages')->onDelete('cascade');
        });

        Schema::create('page_translations', function(Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedInteger('page_id')->nullable()->default(null);
            $table->unsignedInteger('language_id')->nullable()->default(null);
            $table->string('name')->nullable()->default(null);
            $table->string('slug')->unique()->nullable()->default(null);
            $table->text('content')->nullable()->default(null);
            $table->string('meta_title')->nullable()->default(null);
            $table->string('meta_description')->nullable()->default(null);
            $table->timestamps();

            $table->foreign('page_id')->references('id')->on('pages')->onDelete('cascade');
            $table->foreign('language_id')->references('id')->on('languages')->onDelete('cascade');
        });


        $countryModel = Country::whereCode('nz')->first();
        $countryModel->update(['is_active' => 1]);
        $siteCurrency = SiteCurrency::create([
            'name' => 'NZ Dollars',
            'code' => 'NZD',
            'symbol' => '$',
            'conversion_rate' => 1,
            'status' => 'ENABLED'
        ]);

        Configuration::create([
            'configuration_key' => 'general_site_currency',
            'configuration_value' => $siteCurrency->id,
        ]);

        Configuration::create([
            'configuration_key' => 'tax_default_country',
            'configuration_value' => $countryModel->id,
        ]);

        Configuration::create([
            'configuration_key' => 'tax_enabled',
            'configuration_value' => 1,
        ]);

        Configuration::create([
            'configuration_key' => 'tax_percentage',
            'configuration_value' => 15,
        ]);

        Configuration::create([
            'configuration_key' => 'general_site_title',
            'configuration_value' => 'AvoRed an Laravel Ecommerce'
        ]);
        Configuration::create([
            'configuration_key' => 'general_site_description',
            'configuration_value' => 'AvoRed is a free open-source e-commerce application development platform written in PHP based on Laravel. Its an ingenuous and modular e-commerce that is easily customizable according to your needs, with a modern responsive mobile friendly interface as default'
        ]);
        Configuration::create([
            'configuration_key' => 'general_site_description',
            'configuration_value' => 'AvoRed Laravel Ecommerce
        ']);

        $accountMenuGroup = MenuGroup::create([
            'name' => 'My Account',
            'identifier' => 'my-account'
        ]);

        Menu::create([
            'name' => 'Account Overview',
            'menu_group_id' => $accountMenuGroup->id,
            'route' => 'my-account.home',
        ]);
        Menu::create([
            'name' => 'Edit Account',
            'menu_group_id' => $accountMenuGroup->id,
            'route' => 'my-account.edit',
        ]);
        Menu::create([
            'name' => 'Upload Image',
            'menu_group_id' => $accountMenuGroup->id,
            'route' => 'my-account.upload-image',
        ]);
        Menu::create([
            'name' => 'My Orders',
            'menu_group_id' => $accountMenuGroup->id,
            'route' => 'my-account.order.list',
        ]);
        Menu::create([
            'name' => 'My Addresses',
            'menu_group_id' => $accountMenuGroup->id,
            'route' => 'my-account.address.index',
        ]);
        Menu::create([
            'name' => 'My Wishlist',
            'menu_group_id' => $accountMenuGroup->id,
            'route' => 'my-account.wishlist.list',
        ]);
        Menu::create([
            'name' => 'Change Password',
            'menu_group_id' => $accountMenuGroup->id,
            'route' => 'my-account.change-password',
        ]);
        Menu::create([
            'name' => 'Logout',
            'menu_group_id' => $accountMenuGroup->id,
            'route' => 'logout',
        ]);
        
        $menuGroup = MenuGroup::create([
            'name' => 'Main Menu',
            'identifier' => 'main-menu',
            'is_default' => 1
        ]);

        
        Menu::create([
            'name' => 'My Account',
            'menu_group_id' => $menuGroup->id,
            'route' => 'my-account.home',
            'sort_order' => 400
        ]);
        Menu::create([
            'name' => 'Cart',
            'menu_group_id' => $menuGroup->id,
            'route' => 'cart.view',
            'sort_order' => 500
        ]);
        Menu::create([
            'name' => 'Checkout',
            'menu_group_id' => $menuGroup->id,
            'route' => 'checkout.index',
            'sort_order' => 600
        ]);
    }
471236
public function up()
    {
        //looks like these two didn't work in previous migrations
        dbexec('DROP TABLE `#__content_rating`');
        dbexec("DELETE FROM `#__components` WHERE `option` IN  ('com_media', 'com_menus', 'com_modules')");

        //add github gist plugin
        dbexec("INSERT INTO `#__plugins` (`id`, `name`, `element`, `folder`, `access`, `ordering`, `published`, `iscore`, `client_id`, `checked_out`, `checked_out_time`, `params`) VALUES (49, 'Content Filter - GithubGist', 'gist', 'contentfilter', 0, 0, 0, 0, 0, 0, '0000-00-00 00:00:00', '')");

        //remove the syntax plugin
        dbexec("DELETE FROM `#__plugins` WHERE `element` IN ('syntax', 'ptag') ");

        //remove anahita from nodes and edges table names
        if (!dbexists('SHOW TABLES LIKE "#__nodes"')) {
            dbexec('RENAME TABLE #__anahita_nodes TO #__nodes');
        }

        if (!dbexists('SHOW TABLES LIKE "#__edges"')) {
            dbexec('RENAME TABLE #__anahita_edges TO #__edges');
        }

        //UTF-8 conversions
        dbexec('ALTER DATABASE CHARACTER SET utf8');
        dbexec('ALTER TABLE `#__edges` CHARACTER SET utf8');
        dbexec('ALTER TABLE `#__nodes` CHARACTER SET utf8');

        dbexec('ALTER TABLE `#__nodes` CHANGE name name VARBINARY(255)');
        dbexec('ALTER TABLE `#__nodes` CHANGE name name VARCHAR(255) CHARACTER SET utf8');

        dbexec('ALTER TABLE `#__nodes` CHANGE alias alias VARBINARY(255)');
        dbexec('ALTER TABLE `#__nodes` CHANGE alias alias VARCHAR(255) CHARACTER SET utf8');

        dbexec('ALTER TABLE `#__nodes` CHANGE body body MEDIUMBLOB');
        dbexec('ALTER TABLE `#__nodes` CHANGE body body MEDIUMTEXT CHARACTER SET utf8mb4');

        dbexec('ALTER TABLE `#__nodes` CHANGE excerpt excerpt TEXT CHARACTER SET utf8mb4');

        dbexec('ALTER TABLE `#__nodes` CHANGE person_given_name person_given_name VARBINARY(255)');
        dbexec('ALTER TABLE `#__nodes` CHANGE person_given_name person_given_name VARCHAR(255) CHARACTER SET utf8');

        dbexec('ALTER TABLE `#__nodes` CHANGE person_family_name person_family_name VARBINARY(255)');
        dbexec('ALTER TABLE `#__nodes` CHANGE person_family_name person_family_name VARCHAR(255) CHARACTER SET utf8');

        dbexec('ALTER TABLE `#__migrator_migrations` CHARACTER SET utf8');
        dbexec('ALTER TABLE `#__migrator_versions` CHARACTER SET utf8');
        dbexec('ALTER TABLE `#__opensocial_profiles` CHARACTER SET utf8');
        dbexec('ALTER TABLE `#__opensocial_profiles` CHARACTER SET utf8');

        //move these to related components
        dbexec('ALTER TABLE `#__invites_tokens` CHARACTER SET utf8');
        dbexec('ALTER TABLE `#__opensocial_profiles` CHARACTER SET utf8');
        dbexec('ALTER TABLE `#__subscriptions_coupons` CHARACTER SET utf8');
        dbexec('ALTER TABLE `#__subscriptions_packages` CHARACTER SET utf8');
        dbexec('ALTER TABLE `#__subscriptions_transactions` CHARACTER SET utf8');
        dbexec('ALTER TABLE `#__subscriptions_vats` CHARACTER SET utf8');
        dbexec('ALTER TABLE `#__todos_todos` CHARACTER SET utf8');
        dbexec('ALTER TABLE `#__topics_topics` CHARACTER SET utf8');

        dbexec('ALTER TABLE `#__users` CHARACTER SET utf8');

        dbexec('ALTER TABLE `#__users` CHANGE name name VARBINARY(255)');
        dbexec('ALTER TABLE `#__users` CHANGE name name VARCHAR(255) CHARACTER SET utf8');

        //updating comments

        $timeThen = microtime(true);
        $db = AnService::get('anahita:database');

        //change comment formats from html to string
        $entities = dbfetch('SELECT id, body FROM `#__nodes` WHERE type LIKE "ComBaseDomainEntityComment%" ');

        dboutput("Updating comments. This WILL take a while ...\n");

        foreach ($entities as $entity) {
            $id = $entity['id'];
            $body = strip_tags($entity['body']);

            $db->update('nodes', array('body' => $body), ' WHERE id='.$id);
        }

        dboutput("Comments updated!\n");

        $timeDiff = microtime(true) - $timeThen;
        dboutput("TIME: ($timeDiff)"."\n");
    }
818697
public function up ()
    {

        // categories table
        Schema::create(config('categories.categories_table_name') , function (Blueprint $table) {
            $table->engine = "InnoDB";
            $table->increments('id');
            $table->string('title' , 200);
            $table->string('slug' , 250);
            $table->string('description' , 180)->nullable();
            $table->string('model_type' , 200);
            $table->integer('count')->default(0);
            $table->integer('parent')->default(0);
            $table->text('meta')->nullable(); // for custom fields
            $this->makeOtherFields($table);
            $table->softDeletes();
            $table->timestamps();
        });

        // relation table
        Schema::create(config('categories.relation_table_name') , function (Blueprint $table) {
            $table->engine = "InnoDB";
            $table->integer('categorieable_id');
            $table->string('categorieable_type' , 200);
            $table->integer('categories_id')->unsigned()->index();
            $table->foreign('categories_id')->references('id')->on('categories')->onDelete('cascade');
        });

        // insert default category when migrating
        \Illuminate\Support\Facades\DB::table('categories')->insert([
            'id' => 1 ,
            'title' => config('categories.default_category.title') ,
            'slug' => config('categories.default_category.slug') ,
            'model_type' => 'NONE'
        ]);

    }
1108754
public function up()
    {
        Schema::create('scaffoldinterfaces', function (Blueprint $table) {
            $table->increments('id')->unsigned();
            $table->String('package');
            $table->String('migration');
            $table->String('model');
            $table->String('controller');
            $table->String('views');
            $table->String('tablename');
            $table->timestamps();
        });
        Schema::create('relations', function (Blueprint $table) {
            $table->increments('id')->unsigned();
            $table->integer('scaffoldinterface_id')->unsigned();
            $table->String('to');
            $table->String('having');
            $table->foreign('scaffoldinterface_id')->references('id')->on('scaffoldinterfaces')->onDelete('cascade');
            $table->timestamps();
        });
    }