Skip to content

Database Migrations #1075

Description

@kshysius

Hi,

I add this file 20180617100537_create_auth_tables.php to Database/Migrations

In controller add this:

$migrate = \Config\Services::migrations();

echo $migrate->current();

This is my 20180617100537_create_auth_tables.php

<?php namespace Auth\Database\Migrations;

use CodeIgniter\Database\Migration;

class Migration_create_auth_tables extends Migration {

	public function up(){

		/*
		 * Users Table
		 */
		$this->forge->addField([

			'id'				=> ['type' => 'int', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
			'email'				=> ['type' => 'varchar', 'constraint' => 255],
			'first_name'		=> ['type' => 'varchar', 'constraint' => 30, 'null' => true],
			'last_name'			=> ['type' => 'varchar', 'constraint' => 30, 'null' => true],
			'password_hash'		=> ['type' => 'varchar', 'constraint' => 255],
			'reset_hash'		=> ['type' => 'varchar', 'constraint' => 255, 'null' => true],
			'reset_time'		=> ['type' => 'datetime', 'null' => true],
			'activate_hash'		=> ['type' => 'varchar', 'constraint' => 255, 'null' => true],
			'status'			=> ['type' => 'varchar', 'constraint' => 255, 'null' => true],
			'status_message'	=> ['type' => 'varchar', 'constraint' => 255, 'null' => true],
			'active'			=> ['type' => 'tinyint', 'constraint' => 1, 'null' => 0, 'default' => 0],
			'force_pass_reset'	=> ['type' => 'tinyint', 'constraint' => 1, 'null' => 0, 'default' => 0],
			'deleted'			=> ['type' => 'tinyint', 'constraint' => 1, 'null' => 0, 'default' => 0],
			'permissions'		=> ['type' => 'text', 'null' => true],
			'created_at'		=> ['type' => 'datetime', 'null' => true],
			'updated_at'		=> ['type' => 'datetime', 'null' => true],

		]);

		$this->forge->addKey('id', true);

		$this->forge->addKey('email');

		$this->forge->createTable('users', true);

	}

	public function down() {

		$this->forge->dropTable('users', true);
		
	}

}

And I get this error:

The migration class "App\Database\Migrations\Migration_create_auth_tables" could not be found.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions