R
R
Rishat Sultanov2017-09-09 15:55:47
CodeIgniter
Rishat Sultanov, 2017-09-09 15:55:47

Migration runs but does not create my table how to solve?

Good afternoon.
In general, I’m doing migration lessons for this: you
did everything as it says there. In response I get:
Migrations ran successfully!
But only the migrations table is created and that's it.
My implemented migration, which should create a users table, does not want to be created.
Project

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Buksha, 2017-09-09
@rishatss

I didn't find a migrations folder with migrations in your project...
Read more here
1. Create a migrations folder in the application folder . 2. In the migrations folder , create a file, for example 001_add_tables.php 3. Enter the following in the file:

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Migration_Add_tables extends CI_Migration
{
    public function up()
    {
        $this->dbforge->add_field([
            'id' => [
                'type' => 'INT',
                'constraint' => 5,
                'unsigned' => TRUE,
                'auto_increment' => TRUE
            ],
            'title' => [
                'type' => 'VARCHAR',
                'constraint' => 100,
            ],
            'state' => [
                'type' => 'VARCHAR',
                'constraint' => 1,
                'default' => 0,
            ],
        ]);

        $this->dbforge->add_key('id', TRUE);
        $this->dbforge->create_table('modules');
    }

    public function down()
    {
        $this->dbforge->drop_table('modules');
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question