💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
### 数据库迁移 命令行模式下,进入项目根目录( aa 所在目录),创建 ~~~ php aa migrate:create create_test ~~~ 该命令会生成文件 ~~~ /console/migration/_2017_12_02_03_32_50_create_test.php ~~~ 修改代码 ~~~ <?php namespace console\migration; use aaphp\console\Migration; /** * 数据库迁移例子 * Class _2017_12_02_03_32_50_create_test * @package console\migration */ class _2017_12_02_03_32_50_create_test extends Migration { /** * 升级数据库 */ public function up() { $sql="CREATE TABLE `{$this->prefix}test` ( `id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(32) NOT NULL DEFAULT '' COMMENT '用户名', `password` varchar(32) NOT NULL DEFAULT '' COMMENT '密码', `age` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '年龄', `city` varchar(255) DEFAULT NULL COMMENT '城市', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='测试'"; $this->execute($sql); } /** * 降级数据库 */ public function down() { $sql="DROP table `{$this->prefix}test`"; $this->execute($sql); } } ~~~ 升级,执行up方法,即创建表 test ~~~ php aa migrate:up ~~~ 降级,执行down方法,即删除表 test ~~~ // php aa migrate:down 降级数量 php aa migrate:down 1 ~~~