Files
cm-ggotmaeule-backend/application/migrations/20170101000001_apps.php

710 lines
18 KiB
PHP

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Migration_apps extends CI_Migration {
public function up()
{
// apps table
$this->dbforge->add_field(array(
'app_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'auto_increment' => TRUE,
'comment' => 'PK',
),
'app_package' => array(
'type' => 'VARCHAR',
'constraint' => '255',
'default' => '',
'comment' => '패키지명',
),
'app_name' => array(
'type' => 'VARCHAR',
'constraint' => '255',
'default' => '',
'comment' => '어플 이름',
),
'app_sort' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'default' => 0,
'comment' => '정렬순서',
),
'app_policy' => array(
'type' => 'TEXT',
'null' => true,
'comment' => '개인정보취급방침',
),
'app_created_at' => array(
'type' => 'DATETIME',
'null' => true,
'comment' => '생성시간',
),
'app_updated_at' => array(
'type' => 'DATETIME',
'null' => true,
'comment' => '업데이트시간',
),
));
$this->dbforge->add_key('app_id', TRUE);
$this->dbforge->create_table('apps');
// contents_category table
$this->dbforge->add_field(array(
'cat_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'auto_increment' => TRUE,
'comment' => 'PK',
),
'app_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'default' => 0,
'comment' => '앱 PK',
),
'cat_parent' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'default' => 0,
'comment' => '부모 카테고리',
),
'cat_depth' => array(
'type' => 'TINYINT',
'constraint' => 3,
'unsigned' => TRUE,
'default' => 0,
'comment' => '차수',
),
'cat_code' => array(
'type' => 'VARCHAR',
'constraint' => '100',
'default' => '',
'comment' => '카테고리코드',
),
'cat_name' => array(
'type' => 'VARCHAR',
'constraint' => '255',
'default' => '',
'comment' => '카테고리명',
),
'cat_publish_time' => array(
'type' => 'time',
'null' => true,
'comment' => '발행예약시간',
),
'cat_sort' => array(
'type' => 'TINYINT',
'constraint' => 3,
'unsigned' => TRUE,
'default' => 0,
'comment' => '정렬순서',
),
));
$this->dbforge->add_key('cat_id', TRUE);
$this->dbforge->add_key('app_id');
$this->dbforge->add_key('cat_code');
$this->dbforge->add_key('cat_sort');
$this->dbforge->create_table('contents_category');
// contents table
$this->dbforge->add_field(array(
'con_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'auto_increment' => TRUE,
'comment' => 'PK',
),
'app_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'default' => 0,
'comment' => '앱 PK',
),
'con_sort' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'default' => 0,
'comment' => '정렬순서',
),
'cat1_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'default' => 0,
'comment' => '1차 카테고리 PK',
),
'cat2_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'default' => 0,
'comment' => '2차 카테고리 PK',
),
'cat3_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'default' => 0,
'comment' => '3차 카테고리 PK',
),
'cat4_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'default' => 0,
'comment' => '4차 카테고리 PK',
),
'user_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'default' => 0,
'comment' => '회원 PK',
),
'user_name' => array(
'type' => 'VARCHAR',
'constraint' => 100,
'null' => true,
'comment' => '작성자명',
),
'con_title' => array(
'type' => 'VARCHAR',
'constraint' => 255,
'null' => true,
'comment' => '제목',
),
'con_content' => array(
'type' => 'TEXT',
'null' => true,
'comment' => '내용',
),
'crawl_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'default' => 0,
'comment' => '수집목록 PK',
),
'con_origin_url' => array(
'type' => 'VARCHAR',
'constraint' => 255,
'null' => true,
'comment' => '원글주소',
),
'con_hit' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'default' => 0,
'comment' => '조회수',
),
'con_created_at' => array(
'type' => 'DATETIME',
'null' => true,
'comment' => '생성시간',
),
'con_updated_at' => array(
'type' => 'DATETIME',
'null' => true,
'comment' => '업데이트시간',
),
'con_published_at' => array(
'type' => 'DATETIME',
'null' => true,
'comment' => '발행시간',
),
'is_open' => array(
'type' => 'TINYINT',
'constraint' => 3,
'unsigned' => TRUE,
'default' => 0,
'comment' => '발행여부',
),
'is_del' => array(
'type' => 'TINYINT',
'constraint' => 3,
'unsigned' => TRUE,
'default' => 0,
'comment' => '삭제여부',
),
));
$this->dbforge->add_key('con_id', TRUE);
$this->dbforge->add_key('app_id');
$this->dbforge->add_key('con_sort');
$this->dbforge->add_key('cat_id');
$this->dbforge->add_key('user_id');
$this->dbforge->create_table('contents');
// contents_comment table
$this->dbforge->add_field(array(
'com_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'auto_increment' => TRUE,
'comment' => 'PK',
),
'con_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'default' => 0,
'comment' => '컨텐츠 PK',
),
'app_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'default' => 0,
'comment' => '앱 PK',
),
'con_user_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'default' => 0,
'comment' => '컨텐츠 작성자 PK',
),
'user_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'default' => 0,
'comment' => '댓글 작성자 PK',
),
'com_content' => array(
'type' => 'TEXT',
'null' => true,
'comment' => '댓글내용',
),
'com_created_at' => array(
'type' => 'DATETIME',
'null' => true,
'comment' => '생성시간',
),
'com_updated_at' => array(
'type' => 'DATETIME',
'null' => true,
'comment' => '업데이트시간',
),
));
$this->dbforge->add_key('com_id', TRUE);
$this->dbforge->add_key('con_id');
$this->dbforge->add_key('app_id');
$this->dbforge->add_key('user_id');
$this->dbforge->create_table('contents_comment');
// contents_like table
$this->dbforge->add_field(array(
'like_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'auto_increment' => TRUE,
'comment' => 'PK',
),
'con_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'default' => 0,
'comment' => '컨텐츠 PK',
),
'app_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'default' => 0,
'comment' => '앱 PK',
),
'user_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'default' => 0,
'comment' => 'Like 한 회원 PK',
),
'user_token' => array(
'type' => 'VARCHAR',
'constraint' => 255,
'null' => TRUE,
'comment' => 'Like 한 회원 TOKEN',
),
'target_user_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'default' => 0,
'comment' => 'Like 당한 회원 PK',
),
'like_at' => array(
'type' => 'DATETIME',
'null' => true,
'comment' => '좋아요한 시간',
),
));
$this->dbforge->add_key('like_id', TRUE);
$this->dbforge->add_key('con_id');
$this->dbforge->add_key('app_id');
$this->dbforge->add_key('user_id');
$this->dbforge->create_table('contents_like');
// contents_bookmark table
$this->dbforge->add_field(array(
'bookmark_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'auto_increment' => TRUE,
'comment' => 'PK',
),
'con_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'default' => 0,
'comment' => '컨텐츠 PK',
),
'app_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'default' => 0,
'comment' => '앱 PK',
),
'user_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'default' => 0,
'comment' => 'Like 한 회원 PK',
),
'target_user_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'default' => 0,
'comment' => 'Like 당한 회원 PK',
),
'bookmark_at' => array(
'type' => 'DATETIME',
'null' => true,
'comment' => '좋아요한 시간',
),
));
$this->dbforge->add_key('bookmark_id', TRUE);
$this->dbforge->add_key('con_id');
$this->dbforge->add_key('app_id');
$this->dbforge->add_key('user_id');
$this->dbforge->create_table('contents_bookmark');
// notice table
$this->dbforge->add_field(array(
'notice_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'auto_increment' => TRUE,
'comment' => 'PK',
),
'app_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'default' => 0,
'comment' => '앱 PK',
),
'user_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'default' => 0,
'comment' => '작성한 회원 PK',
),
'user_name' => array(
'type' => 'VARCHAR',
'constraint' => 100,
'null' => true,
'comment' => '작성자명',
),
'notice_title' => array(
'type' => 'VARCHAR',
'constraint' => 255,
'null' => true,
'comment' => '공지제목',
),
'notice_content' => array(
'type' => 'TEXT',
'null' => true,
'comment' => '공지내용',
),
'created_at' => array(
'type' => 'DATETIME',
'null' => true,
'comment' => '작성 시간',
),
'updated_at' => array(
'type' => 'DATETIME',
'null' => true,
'comment' => '최종업데이트 시간',
),
));
$this->dbforge->add_key('notice_id', TRUE);
$this->dbforge->add_key('user_id');
$this->dbforge->create_table('notice');
// qna table
$this->dbforge->add_field(array(
'qna_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'auto_increment' => TRUE,
'comment' => 'PK',
),
'app_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'default' => 0,
'comment' => '앱 PK',
),
'user_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'default' => 0,
'comment' => '작성한 회원 PK',
),
'user_name' => array(
'type' => 'VARCHAR',
'constraint' => 100,
'null' => true,
'comment' => '작성자명',
),
'qna_title' => array(
'type' => 'vARCHAR',
'constraint' => 255,
'null' => true,
'comment' => '문의제목',
),
'qna_content' => array(
'type' => 'TEXT',
'null' => true,
'comment' => '문의내용',
),
'created_at' => array(
'type' => 'DATETIME',
'null' => true,
'comment' => '작성 시간',
),
'updated_at' => array(
'type' => 'DATETIME',
'null' => true,
'comment' => '최종업데이트 시간',
),
));
$this->dbforge->add_key('qna_id', TRUE);
$this->dbforge->add_key('user_id');
$this->dbforge->create_table('qna');
// contents_tag table
$this->dbforge->add_field(array(
'tag_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'auto_increment' => TRUE,
'comment' => 'PK',
),
'con_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'default' => 0,
'comment' => '컨텐츠 PK',
),
'app_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'default' => 0,
'comment' => '앱 PK',
),
'tag_name' => array(
'type' => 'VARCHAR',
'constraint' => 255,
'null' => TRUE,
'comment' => '태그명',
),
));
$this->dbforge->add_key('tag_id', TRUE);
$this->dbforge->add_key('con_id');
$this->dbforge->add_key('app_id');
$this->dbforge->create_table('contents_tag');
// fcm_result table
$this->dbforge->add_field(array(
'id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'auto_increment' => TRUE,
'comment' => 'PK',
),
'sendto' => array(
'type' => 'VARCHAR',
'constraint' => '5',
'default' => '',
'comment' => '발송대상',
),
'topic' => array(
'type' => 'VARCHAR',
'constraint' => '100',
'default' => '',
'comment' => '토픽',
),
'user_token' => array(
'type' => 'VARCHAR',
'constraint' => '255',
'default' => '',
'comment' => '토큰',
),
'title' => array(
'type' => 'VARCHAR',
'constraint' => '255',
'default' => '',
'comment' => '제목',
),
'message' => array(
'type' => 'VARCHAR',
'constraint' => '255',
'default' => '',
'comment' => '내용',
),
'message_id' => array(
'type' => 'VARCHAR',
'constraint' => '20',
'default' => '',
'comment' => '메세지아이디',
),
'success' => array(
'type' => 'TINYINT',
'constraint' => 3,
'default' => 0,
'comment' => '성공',
),
'failure' => array(
'type' => 'TINYINT',
'constraint' => 3,
'default' => 0,
'comment' => '실패',
),
'response' => array(
'type' => 'VARCHAR',
'constraint' => '255',
'default' => '',
'comment' => '응답값',
),
'regdate' => array(
'type' => 'DATETIME',
'null' => true,
'comment' => '등록일',
),
));
$this->dbforge->add_key('id', TRUE);
$this->dbforge->create_table('fcm_result');
// crawl_list table
$this->dbforge->add_field(array(
'crawl_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'auto_increment' => TRUE,
'comment' => 'PK',
),
'app_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'default' => 0,
'comment' => '앱 PK',
),
'cat_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'default' => 0,
'comment' => '카테고리 PK',
),
'crawl_title' => array(
'type' => 'VARCHAR',
'constraint' => 255,
'null' => true,
'comment' => '제목',
),
'site_type' => array(
'type' => 'TINYINT',
'constraint' => 3,
'unsigned' => TRUE,
'default' => 0,
'comment' => '사이트 종류',
),
'site_key' => array(
'type' => 'VARCHAR',
'constraint' => 255,
'null' => true,
'comment' => '크롤할주소',
),
'created_at' => array(
'type' => 'DATETIME',
'null' => true,
'comment' => '생성시간',
),
'updated_at' => array(
'type' => 'DATETIME',
'null' => true,
'comment' => '생성시간',
),
'latest_crawled_at' => array(
'type' => 'DATETIME',
'null' => true,
'comment' => '최종 수집시간',
),
));
$this->dbforge->add_key('crawl_id', TRUE);
$this->dbforge->add_key('app_id');
$this->dbforge->create_table('crawl_list');
}
public function down()
{
}
}