/**
  * Create the table schema.
  *
  * @param Blueprint $table
  *
  * @return mixed
  */
 protected function create(Blueprint $table)
 {
     $table->increments('id');
     $table->unsignedInteger('job_id');
     $table->string('name');
     $table->unique(['job_id', 'name']);
     $table->timestamps();
 }
 public function testIndexDefaultNames()
 {
     $blueprint = new Blueprint('users');
     $blueprint->unique(array('foo', 'bar'));
     $commands = $blueprint->getCommands();
     $this->assertEquals('users_foo_bar_unique', $commands[0]->index);
     $blueprint = new Blueprint('users');
     $blueprint->index('foo');
     $commands = $blueprint->getCommands();
     $this->assertEquals('users_foo_index', $commands[0]->index);
 }
 /**
  * Add the field type column.
  *
  * @param Blueprint           $table
  * @param AssignmentInterface $assignment
  */
 public function addColumn(Blueprint $table, AssignmentInterface $assignment)
 {
     // Skip if the column already exists.
     if ($this->schema->hasColumn($table->getTable(), $this->fieldType->getColumnName() . '_id')) {
         return;
     }
     $table->string($this->fieldType->getColumnName() . '_type')->nullable(!$assignment->isRequired());
     $table->integer($this->fieldType->getColumnName() . '_id')->nullable(!$assignment->isRequired());
     if ($assignment->isUnique() && $assignment->isTranslatable()) {
         $table->unique([$this->fieldType->getColumnName() . '_type', $this->fieldType->getColumnName() . '_id']);
     }
 }
 /**
  * Give me the tools and I will tell you what my schema is...
  *
  * @param Blueprint $table The blueprint for the database table.
  * @return Blueprint The designed database table schema.
  */
 public static function describeSchema(Blueprint $table)
 {
     $table->increments('id');
     $table->string('uuid', 36);
     $table->integer('playhead')->unsigned();
     $table->text('metadata');
     $table->text('payload');
     $table->string('recorded_on', 32);
     $table->text('type');
     $table->unique(['uuid', 'playhead']);
     return $table;
 }
Beispiel #5
0
 protected function create(Blueprint $table)
 {
     $table->create();
     $table->increments('id');
     $table->integer('group_id')->unsigned()->default(3);
     $table->string('username', 200)->default('');
     $table->string('password', 60)->default('');
     $table->string('email', 80)->default('');
     $table->string('title', 50)->nullable();
     $table->string('realname', 40)->nullable();
     $table->string('url', 100)->nullable();
     $table->string('location', 30)->nullable();
     $table->text('signature')->nullable();
     $table->integer('disp_topics')->unsigned()->nullable();
     $table->integer('disp_posts')->unsigned()->nullable();
     $table->integer('email_setting')->unsigned()->default(1);
     $table->boolean('notify_with_post')->default(false);
     $table->boolean('auto_notify')->default(false);
     $table->boolean('show_smilies')->default(true);
     $table->boolean('show_img')->default(true);
     $table->boolean('show_img_sig')->default(true);
     $table->boolean('show_avatars')->default(true);
     $table->boolean('show_sig')->default(true);
     $table->float('timezone')->default(0);
     $table->boolean('dst')->default(false);
     $table->integer('time_format')->unsigned()->default(0);
     $table->integer('date_format')->unsigned()->default(0);
     $table->string('language', 25)->default('');
     $table->string('style', 25)->default('');
     $table->integer('num_posts')->unsigned()->default(0);
     $table->integer('last_post')->unsigned()->nullable();
     $table->integer('last_search')->unsigned()->nullable();
     $table->integer('last_email_sent')->unsigned()->nullable();
     $table->integer('last_report_sent')->unsigned()->nullable();
     $table->integer('registered')->unsigned()->default(0);
     $table->string('registration_ip', 35)->default('0.0.0.0');
     $table->integer('last_visit')->unsigned()->default(0);
     $table->string('admin_note', 30)->nullable();
     $table->string('activate_string', 80)->nullable();
     $table->string('activate_key', 8)->nullable();
     $table->string('remember_token')->nullable();
     $table->unique('username');
     $table->index('registered');
 }
 /**
  * @param Blueprint $table table
  * @return Blueprint
  */
 private function documentSchema(Blueprint $table)
 {
     $table->string('parentId', 255)->default('');
     $table->string('instanceId', 255)->default('');
     // users
     $table->string('userType', '16')->default('normal');
     $table->string('userId', 255);
     $table->string('writer', 255);
     $table->string('email')->nullable();
     // 비회원 작성일때 email 받기?
     $table->string('certifyKey', 255);
     // nonmember document's password
     // count
     $table->integer('readCount')->default(0);
     $table->integer('commentCount')->default(0);
     $table->integer('assentCount')->default(0);
     $table->integer('dissentCount')->default(0);
     // display contents config values
     $table->enum('approved', array('approved', 'waiting', 'rejected'))->default('approved');
     $table->enum('published', array('published', 'waiting', 'reserved', 'rejected'))->default('published');
     // temp 대신 draft가 어떨까?
     $table->enum('status', array('public', 'temp', 'trash', 'private', 'notice'))->default('public');
     $table->enum('display', array('visible', 'secret', 'hidden'))->default('visible');
     // search
     $table->string('locale', 255)->default('');
     // multi-language support. ko, en, jp, ...
     $table->string('title', 255);
     $table->text('content');
     $table->text('pureContent');
     $table->timestamp('createdAt');
     $table->timestamp('publishedAt');
     $table->timestamp('updatedAt');
     $table->timestamp('deletedAt')->nullable();
     // 대댓글 처리를 위한 트리용 컬럼 추가 ex.) head, parent, depth
     $table->string('head', 50);
     // timestamp + uuid (ex. 1430369257-bd1fc797-474f-47a6-bedb-867a376490f2)
     $table->string('reply', 200)->nullable();
     $table->string('listOrder', 250);
     $table->string('ipaddress', 16);
     $table->index('createdAt');
     $table->unique(['head', 'reply']);
     return $table;
 }
 /**
  * @param Blueprint           $table
  * @param AssignmentInterface $assignment
  */
 public function addColumn(Blueprint $table, AssignmentInterface $assignment)
 {
     // Skip if the column already exists.
     if ($this->schema->hasColumn($table->getTable(), $this->fieldType->getColumnName())) {
         return;
     }
     /**
      * Add the column to the table.
      *
      * @var Blueprint|Fluent $column
      */
     $column = $table->{$this->fieldType->getColumnType()}($this->fieldType->getColumnName(), 11, array_get($this->fieldType->getConfig(), 'decimals', 2))->nullable(!$assignment->isTranslatable() ? !$assignment->isRequired() : true);
     if (!str_contains($this->fieldType->getColumnType(), ['text', 'blob'])) {
         $column->default(array_get($this->fieldType->getConfig(), 'default_value'));
     }
     // Mark the column unique if desired and not translatable.
     if ($assignment->isUnique() && !$assignment->isTranslatable()) {
         $table->unique($this->fieldType->getColumnName());
     }
 }
Beispiel #8
0
 /**
  * Criar indice unico, respeitando se deve ou nao adicionar o inquilno.
  */
 public function unique($columns, $name = null, $withTenant = false)
 {
     $columns = (array) $columns;
     // Verificar se deve adicionar a coluna do inquilino
     if ($withTenant && in_array(self::tenantField(), $columns) != true) {
         $columns = array_merge([], [self::tenantField()], $columns);
     }
     return parent::unique($columns, $name);
 }
 public function testAddingUniqueKey()
 {
     $blueprint = new Blueprint('users');
     $blueprint->unique('foo', 'bar');
     $statements = $blueprint->toSql($this->getGrammar());
     $this->assertEquals(1, count($statements));
     $this->assertEquals('create unique index bar on "users" ("foo")', $statements[0]);
 }
 public function testAddingUniqueKey()
 {
     $blueprint = new Blueprint('users');
     $blueprint->unique('foo', 'bar');
     $statements = $blueprint->toSql($this->getGrammar());
     $this->assertEquals(1, count($statements));
     $this->assertEquals('alter table `users` add unique bar(`foo`)', $statements[0]);
 }
 /**
  * Update the field type column to the table.
  *
  * @param Blueprint           $table
  * @param AssignmentInterface $assignment
  */
 public function updateColumn(Blueprint $table, AssignmentInterface $assignment)
 {
     // Skip if no column type.
     if (!$this->fieldType->getColumnType()) {
         return;
     }
     // Skip if the column doesn't exists.
     if (!$this->schema->hasColumn($table->getTable(), $this->fieldType->getColumnName())) {
         return;
     }
     /**
      * Update the column to the table.
      *
      * @var Blueprint|Fluent $column
      */
     $column = call_user_func_array([$table, $this->fieldType->getColumnType()], array_filter([$this->fieldType->getColumnName(), $this->fieldType->getColumnLength()]));
     $column->nullable(!$assignment->isTranslatable() ? !$assignment->isRequired() : true)->change();
     if (!str_contains($this->fieldType->getColumnType(), ['text', 'blob'])) {
         $column->default(array_get($this->fieldType->getConfig(), 'default_value'));
     }
     /**
      * Mark the column unique if desired and not translatable.
      * Otherwise, drop the unique index.
      */
     $connection = $this->schema->getConnection();
     $manager = $connection->getDoctrineSchemaManager();
     $doctrine = $manager->listTableDetails($connection->getTablePrefix() . $table->getTable());
     // The unique index name.
     $unique = md5('unique_' . $this->fieldType->getColumnName());
     /**
      * If the assignment is unique and not translatable
      * and the table does not already have the given the
      * given table index then go ahead and add it.
      */
     if ($assignment->isUnique() && !$assignment->isTranslatable() && !$doctrine->hasIndex($unique)) {
         $table->unique($this->fieldType->getColumnName(), $unique);
     }
     /**
      * If the assignment is NOT unique and not translatable
      * and the table DOES have the given table index
      * then we need to remove.
      */
     if (!$assignment->isUnique() && !$assignment->isTranslatable() && $doctrine->hasIndex($unique)) {
         $column->dropIndex(md5('unique_' . $this->fieldType->getColumnName()));
     }
 }
 public function testAddingUniqueKey()
 {
     $blueprint = new Blueprint('users');
     $blueprint->unique('foo', 'bar');
     $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
     $this->assertEquals(1, count($statements));
     $this->assertEquals('alter table users add constraint bar unique ( foo )', $statements[0]);
 }
 /**
  * @param Blueprint $table table
  * @return Blueprint
  */
 private function setColumns(Blueprint $table)
 {
     $table->string('parentId', 255)->default('');
     $table->string('instanceId', 255)->default('');
     $table->string('type', 255)->default('');
     // users
     $table->string('userType', '16')->default('normal');
     $table->string('userId', 255);
     $table->string('writer', 255);
     $table->string('email')->nullable();
     // 비회원 작성일때 email 받기?
     $table->string('certifyKey', 255);
     // nonmember document's password
     // count
     $table->integer('readCount')->default(0);
     $table->integer('commentCount')->default(0);
     $table->integer('assentCount')->default(0);
     $table->integer('dissentCount')->default(0);
     // display contents config values
     $table->integer('approved')->default(Document::APPROVED_APPROVED);
     $table->integer('published')->default(Document::PUBLISHED_PUBLISHED);
     $table->integer('status')->default(Document::STATUS_PUBLIC);
     $table->integer('display')->default(Document::DISPLAY_VISIBLE);
     $table->integer('format')->default(Document::FORMAT_HTML);
     // search
     $table->string('locale', 255)->default('');
     $table->string('title', 255);
     $table->text('content');
     $table->text('pureContent');
     $table->timestamp('createdAt');
     $table->timestamp('updatedAt');
     $table->timestamp('publishedAt')->nullable();
     $table->timestamp('deletedAt')->nullable();
     $table->string('head', 50);
     $table->string('reply', 200);
     $table->string('ipaddress', 16);
     $table->index('createdAt');
     $table->unique(['head', 'reply']);
     return $table;
 }