본문 바로가기
반응형

migrate3

[Laravel] migration을 이용하여 컬럼 삭제, 수정 하기 Migration을 이용하여 컬럼 삭제, 수정을 하기 위해서는 doctrine/dbal 패키지가 필요하다. 컴포저를 사용하여 해당 패키지를 설치한다. composer require doctrine/dbal 컬럼 속성 변경 Schema::table('test', function (Blueprint $table) { $table->string('name', 50)->change(); }); 컬럼 이름 변경 Schema::table('test', function (Blueprint $table) { $table->renameColumn('from', 'to'); }); 컬럼 삭제 Schema::table('test', function (Blueprint $table) { $table->dropColumn('c.. 2020. 12. 1.
[Laravel] Migration 실행 시 errno: 150 "Foreign key constraint is incorrectly formed") Schema::create('users', function (Blueprint $table) { $table->engine = "InnoDB"; $table->increments('id')->unsigned(); $table->string('name'); $table->string('email')->unique(); $table->string('password'); $table->rememberToken(); $table->timestamps(); }); PK로 지정된 id컬럼을 다른 테이블에서 외래키 값으로 참조하려는 경우 해당 테이블의 외래키 컬럼과 PK로 지정된 컬럼의 속성이 같아야함 integer/ unsigned으로 속성을 주었기 때문에 참조하려는 테이블에서도 integer /unsigned 속.. 2020. 9. 16.
[Laravel] DB, ORM,Migration .env 파일에서 db 정보를 변경 할 수 있다. migration - 마이그레이션은 손쉽게 애플리케이션의 데이터베이스를 수정하고 데이터베이스 스키마를 공유할 수 있도록 해주며 데이터베이스를 위한 버전 컨트롤과 같은 역할을 한다. 마이그레이션은 보통 라라벨의 스키마 빌더와 쌍을 이루어 애플리케이션의 데이터베이스 스키마를 손쉽게 만들 수 있다. 설명은 장황하지만 쉽게 생각하면 수동으로 테이블을 수정,삭제,생성 하는게 아니고 php artison 명령어로 migration을 생성 후 적용 하면 손쉽게 데이터베이스를 수정 할 수 있다. 라라벨 프로젝트를 생성하게 되면 기본적으로 database\migration 디렉토리에 create_users_table.php와 create_password_resets_ta.. 2019. 4. 11.
반응형