obsidian/MyObsidianVault/Knowledgebase/WebDev/2 CodeIgniter/_Course Notes/02.) Migrations - Add entities.md

33 lines
600 B
Markdown
Raw Normal View History

2024-11-10 17:38:07 +01:00
```bash
php spark make:scaffold Product
```
Creates Controller, Model, Migration, Seeder
2024-11-11 08:59:41 +01:00
```php
//up:
$this->forge->addField((["id"=>
2024-12-08 09:19:03 +01:00
["type"=>"INT",
2024-11-11 08:59:41 +01:00
"constraint"=>5,
"auto increment" => true,
"unsigned" => true
],
"name" => ["type"=>"VARCHAR".
"constraint" => 120,
"null" => false
]
]
));
$this->forge->addPrimaryKey("id);
$this->forge->createTable("students");
//down:
$this->forge->dropTable("students");
```
2024-11-13 09:05:39 +01:00
```bash
2024-11-17 12:05:52 +01:00
php spark migrate:status
2024-11-13 09:05:39 +01:00
php spark migrate
```