Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database Migrations #1075

Closed
kshysius opened this issue Jun 17, 2018 · 3 comments
Closed

Database Migrations #1075

kshysius opened this issue Jun 17, 2018 · 3 comments

Comments

@kshysius
Copy link

kshysius commented Jun 17, 2018

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.

@InsiteFX
Copy link
Contributor

This should be asked first in the CodeIgniter 4 Forums.

Also I do not see your config for Migrations...

@kshysius
Copy link
Author

kshysius commented Jun 18, 2018

OK, sorry, next time I asked first in Codeigniter 4 Forum.

<?php namespace Config;

use CodeIgniter\Config\BaseConfig;

My config:

class Migrations extends BaseConfig
{
	
        public $enabled = true;

	public $type = 'timestamp';

	public $table = 'migrations';

	public $currentVersion = 20180617100537;

}

@lonnieezell
Copy link
Member

Sorry, these issues are only for bug reports. this appears to be more of a question. Please ask on the forums.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants