我跟着@jellybool的视频学习。
在cmd命令行上运行了下面的命令。
php artisan make:migration create_articles_table --create=articles
然后在 2015_10_23_022143_create_articles_table.php 中书写了下面的代码
public function up()
{
Schema::create('articles', function (Blueprint $table) {
$table->increments('id');
$table->string('title');
$table->text('content');
$table->timestamps('published_at');
$table->timestamps();
});
}接着在CMD上运行就弹出错误了,数据库里也没有显示articles表,是哪个地方出现了字段重复?
D:\laravel>php artisan migrate [Illuminate\Database\QueryException] SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'created _at' (SQL: create table `articles` (`id` int unsigned not null auto_increme nt primary key, `title` varchar(255) not null, `content` text not null, `cr eated_at` timestamp default 0 not null, `updated_at` timestamp default 0 no t null, `created_at` timestamp default 0 not null, `updated_at` timestamp d efault 0 not null) default character set utf8 collate utf8_unicode_ci) [PDOException] SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'created _at'
我跟着@jellybool的视频学习。
在cmd命令行上运行了下面的命令。
php artisan make:migration create_articles_table --create=articles
然后在 2015_10_23_022143_create_articles_table.php 中书写了下面的代码
public function up()
{
Schema::create('articles', function (Blueprint $table) {
$table->increments('id');
$table->string('title');
$table->text('content');
$table->timestamps('published_at');
$table->timestamps();
});
}接着在CMD上运行就弹出错误了,数据库里也没有显示articles表,是哪个地方出现了字段重复?
D:\laravel>php artisan migrate [Illuminate\Database\QueryException] SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'created _at' (SQL: create table `articles` (`id` int unsigned not null auto_increme nt primary key, `title` varchar(255) not null, `content` text not null, `cr eated_at` timestamp default 0 not null, `updated_at` timestamp default 0 no t null, `created_at` timestamp default 0 not null, `updated_at` timestamp d efault 0 not null) default character set utf8 collate utf8_unicode_ci) [PDOException] SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'created _at'
1.修正BUG站用资源问题,优化程序2.增加关键词搜索3.修改报价4.修正BUG 水印问题5.修改上传方式6.彻底整合论坛,实现一站通7.彻底解决群发垃圾信息问题。注册会员等发垃圾邮件7.彻底解决数据库安全9.修改交易方式.增加网站担保,和直接交易两中10.全站可选生成html.和单独新闻生成html(需要装组建)11. 网站有10中颜色选择适合不同的行业不同的颜色12.修改竞价格排名方式13.修
0
好吧 终于发现了 是我的疏忽大意
$table->timestamps('published_at');
应该改为
$table->timestamp('published_at');timestamps()与timestamp()不同。前者是一个 Laravel 用来管理创建和修改作为created_at和updated_at TIMESTAMP列的方法。所以跟下面的方法重复了,导致出现字段重复的问题
楼主,我执行php artisan migrate
的时候就失败,你怎么可以执行成功
[PDOException]
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using pas
sword: YES)
我用的5.1版本.evn文件修改如下:
DB_HOST=127.0.0.1
DB_DATABASE=homestead
DB_USERNAME=root
DB_PASSWORD=secret
执行上面呢句就报错
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号