Skip to content
Snippets Groups Projects
2020-05-30-101000_add_languages.php 893 B
Newer Older
  • Learn to ignore specific revisions
  • <?php
    
    namespace App\Database\Migrations;
    
    use \CodeIgniter\Database\Migration;
    
    class AddLanguages extends Migration
    {
    
        public function up()
        {
            $this->forge->addField([
                'code' => [
                    'type' => 'VARCHAR',
    
                    'comment' => 'ISO 639-1 language code.',
    
                    'constraint' => 2,
                ],
    
                'name' => [
                    'type' => 'VARCHAR',
                    'comment' => 'English language name.',
                    'constraint' => 191,
                ],
                'native_name' => [
                    'type' => 'VARCHAR',
                    'comment' => 'Native language name.',
                    'constraint' => 191,
                ],
    
            ]);
            $this->forge->addKey('code', true);
            $this->forge->createTable('languages');
        }
    
        public function down()
        {
            $this->forge->dropTable('languages');
        }
    }