Skip to content

Commit

Permalink
rename subscription table to lowercase
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-chepurnoi committed Nov 9, 2016
1 parent 39775d0 commit ea8f72f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ if ($this->db->driverName === 'mysql') {
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
}

$this->createTable('Subscription', [
$this->createTable('subscription', [
'id' => $this->primaryKey(),
'userId' => $this->integer()->notNull(),
'name' => $this->string()->notNull(),
Expand All @@ -54,10 +54,10 @@ $this->createTable('Subscription', [
'updatedAt' => $this->timestamp()->null()
], $tableOptions);

$this->addColumn('User', 'stripeId', $this->string());
$this->addColumn('User', 'cardBrand', $this->string());
$this->addColumn('User', 'cardLastFour', $this->string());
$this->addColumn('User', 'trialEndAt', $this->timestamp()->null());
$this->addColumn('user', 'stripeId', $this->string());
$this->addColumn('user', 'cardBrand', $this->string());
$this->addColumn('user', 'cardLastFour', $this->string());
$this->addColumn('user', 'trialEndAt', $this->timestamp()->null());
```
> Also you can apply migration by the following command:
Expand Down
21 changes: 11 additions & 10 deletions migrations/m160511_085953_init.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function up()
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
}

$this->createTable('Subscription', [
$this->createTable('subscription', [
'id' => $this->primaryKey(),
'userId' => $this->integer()->notNull(),
'name' => $this->string()->notNull(),
Expand All @@ -28,19 +28,20 @@ public function up()
'updatedAt' => $this->timestamp()->null()
], $tableOptions);

$this->addColumn('User', 'stripeId', $this->string());
$this->addColumn('User', 'cardBrand', $this->string());
$this->addColumn('User', 'cardLastFour', $this->string());
$this->addColumn('User', 'trialEndAt', $this->timestamp()->null());
$this->addColumn('user', 'stripeId', $this->string());
$this->addColumn('user', 'cardBrand', $this->string());
$this->addColumn('user', 'cardLastFour', $this->string());
$this->addColumn('user', 'trialEndAt', $this->timestamp()->null());
}

public function down()
{
$this->dropTable('Subscription');
$this->dropColumn('User', 'stripeId');
$this->dropColumn('User', 'cardBrand');
$this->dropColumn('User', 'cardLastFour');
$this->dropColumn('User', 'trialEndAt');
$this->dropTable('subscription');

$this->dropColumn('user', 'stripeId');
$this->dropColumn('user', 'cardBrand');
$this->dropColumn('user', 'cardLastFour');
$this->dropColumn('user', 'trialEndAt');
}

/*
Expand Down
2 changes: 1 addition & 1 deletion models/SubscriptionModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class SubscriptionModel extends ActiveRecord
*/
public static function tableName()
{
return 'Subscription';
return 'subscription';
}

/**
Expand Down
6 changes: 3 additions & 3 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ protected function setupTestDbData()

// Structure :

$db->createCommand()->createTable('Subscription', [
$db->createCommand()->createTable('subscription', [
'id' => 'pk',
'userId' => 'integer not null',
'name' => 'string not null',
Expand All @@ -97,7 +97,7 @@ protected function setupTestDbData()
'updatedAt' => 'timestamp null default null',
])->execute();

$db->createCommand()->createTable('User', [
$db->createCommand()->createTable('user', [
'id' => 'pk',
'username' => 'string',
'email' => 'string',
Expand All @@ -107,7 +107,7 @@ protected function setupTestDbData()
'trialEndAt' => 'timestamp null default null',
])->execute();

$db->createCommand()->insert('User', [
$db->createCommand()->insert('user', [
'username' => 'John Doe',
'email' => '[email protected]'
])->execute();
Expand Down
2 changes: 1 addition & 1 deletion tests/data/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class User extends ActiveRecord implements IdentityInterface
*/
public static function tableName()
{
return 'User';
return 'user';
}

/**
Expand Down

0 comments on commit ea8f72f

Please sign in to comment.