Skip to main content

Yii2 Inventory - Migrate db using command prompt~


Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\cda>cd c:\xampp\htdocs

c:\xampp\htdocs>composer create-project --prefer-dist yiisoft/yii2-app-basic inv
entory
Installing yiisoft/yii2-app-basic (2.0.10)
  - Installing yiisoft/yii2-app-basic (2.0.10)
    Downloading: 100%

Created project in inventory
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing yiisoft/yii2-composer (2.0.5)
    Downloading: 100%

  - Installing swiftmailer/swiftmailer (v5.4.5)
    Downloading: 100%

  - Installing bower-asset/jquery (2.2.4)
    Loading from cache

  - Installing bower-asset/yii2-pjax (v2.0.6)
    Loading from cache

  - Installing bower-asset/punycode (v1.3.2)
    Loading from cache

  - Installing bower-asset/jquery.inputmask (3.2.7)
    Loading from cache

  - Installing cebe/markdown (1.1.1)
    Loading from cache

  - Installing ezyang/htmlpurifier (v4.8.0)
    Loading from cache

  - Installing yiisoft/yii2 (2.0.10)
    Loading from cache

  - Installing yiisoft/yii2-swiftmailer (2.0.6)
    Loading from cache

  - Installing bower-asset/bootstrap (v3.3.7)
    Loading from cache

  - Installing yiisoft/yii2-bootstrap (2.0.6)
    Downloading: 100%

  - Installing yiisoft/yii2-debug (2.0.7)
    Loading from cache

  - Installing bower-asset/typeahead.js (v0.11.1)
    Loading from cache

  - Installing phpspec/php-diff (v1.1.0)
    Loading from cache

  - Installing yiisoft/yii2-gii (2.0.5)
    Downloading: 100%

  - Installing fzaninotto/faker (v1.6.0)
    Downloading: 100%

  - Installing yiisoft/yii2-faker (2.0.3)
    Downloading: 100%

  - Installing sebastian/diff (1.4.1)
    Downloading: 100%

  - Installing sebastian/recursion-context (1.0.2)
    Downloading: 100%

  - Installing sebastian/exporter (1.2.2)
    Downloading: 100%

  - Installing sebastian/comparator (1.2.2)
    Downloading: 100%

  - Installing behat/gherkin (v4.4.5)
    Downloading: 100%

  - Installing symfony/polyfill-mbstring (v1.3.0)
    Loading from cache

  - Installing symfony/dom-crawler (v3.2.1)
    Loading from cache

  - Installing symfony/css-selector (v3.2.1)
    Loading from cache

  - Installing symfony/browser-kit (v3.2.1)
    Downloading: 100%

  - Installing symfony/yaml (v3.2.1)
    Downloading: 100%

  - Installing symfony/event-dispatcher (v3.2.1)
    Downloading: 100%

  - Installing psr/log (1.0.2)
    Downloading: 100%

  - Installing symfony/debug (v3.2.1)
    Downloading: 100%

  - Installing symfony/console (v3.2.1)
    Downloading: 100%

  - Installing symfony/finder (v3.2.1)
    Downloading: 100%

  - Installing psr/http-message (1.0.1)
    Downloading: 100%

  - Installing guzzlehttp/psr7 (1.3.1)
    Downloading: 100%

  - Installing sebastian/version (1.0.6)
    Downloading: 100%

  - Installing sebastian/environment (1.3.8)
    Downloading: 100%

  - Installing phpunit/php-token-stream (1.4.9)
    Downloading: 100%

  - Installing phpunit/php-text-template (1.2.1)
    Downloading: 100%

  - Installing phpunit/php-file-iterator (1.4.2)
    Downloading: 100%

  - Installing phpunit/php-code-coverage (2.2.4)
    Downloading: 100%

  - Installing sebastian/global-state (1.1.1)
    Downloading: 100%

  - Installing doctrine/instantiator (1.0.5)
    Downloading: 100%

  - Installing phpunit/php-timer (1.0.8)
    Downloading: 100%

  - Installing webmozart/assert (1.2.0)
    Downloading: 100%

  - Installing phpdocumentor/reflection-common (1.0)
    Downloading: 100%

  - Installing phpdocumentor/type-resolver (0.2.1)
    Downloading: 100%

  - Installing phpdocumentor/reflection-docblock (3.1.1)
    Downloading: 100%

  - Installing phpspec/prophecy (v1.6.2)
    Downloading: 100%

  - Installing myclabs/deep-copy (1.5.5)
    Downloading: 100%

  - Installing phpunit/phpunit-mock-objects (2.3.8)
    Downloading: 100%

  - Installing phpunit/phpunit (4.8.31)
    Downloading: 100%

  - Installing codeception/base (2.2.7)
    Downloading: 100%

  - Installing codeception/verify (0.3.2)
    Downloading: 100%

  - Installing codeception/specify (0.4.5)
    Downloading: 100%

symfony/browser-kit suggests installing symfony/process ()
symfony/event-dispatcher suggests installing symfony/dependency-injection ()
symfony/event-dispatcher suggests installing symfony/http-kernel ()
symfony/console suggests installing symfony/filesystem ()
symfony/console suggests installing symfony/process ()
phpunit/php-code-coverage suggests installing ext-xdebug (>=2.2.1)
sebastian/global-state suggests installing ext-uopz (*)
phpunit/phpunit suggests installing phpunit/php-invoker (~1.1)
codeception/base suggests installing flow/jsonpath (For using JSONPath in REST m
odule)
codeception/base suggests installing phpseclib/phpseclib (for SFTP option in FTP
 Module)
codeception/base suggests installing league/factory-muffin (For DataFactory modu
le)
codeception/base suggests installing league/factory-muffin-faker (For Faker supp
ort in DataFactory module)
codeception/base suggests installing symfony/phpunit-bridge (For phpunit-bridge
support)
Writing lock file
Generating autoload files
> yii\composer\Installer::postCreateProject
chmod('runtime', 0777)...done.
chmod('web/assets', 0777)...done.
chmod('yii', 0755)...done.


c:\xampp\htdocs>cd invebtory
The system cannot find the path specified.

c:\xampp\htdocs>cd inventory

c:\xampp\htdocs\inventory>yii migrate/create create_table_items
Yii Migration Tool (based on Yii v2.0.10)

Create new migration 'C:\xampp\htdocs\inventory/migrations\m170103_093144_create
_table_items.php'? (yes|no) [no]:yes
New migration created successfully.

Still error after try and error try and error so many time baru berjaya migrate yehuuu~~




Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\shahida.saidon>cd c:\\xampp\htdocs\inventory

c:\xampp\htdocs\inventory>yii migrate
Yii Migration Tool (based on Yii v2.0.10)

Total 4 new migrations to be applied:
        m170104_015108_create_table_items
        m170104_015212_create_table_transaction_types
        m170104_020833_create_table_transactions
        m170104_020933_create_table_transaction_details

Apply the above migrations? (yes|no) [no]:yes
*** applying m170104_015108_create_table_items
PHP Compile Error 'yii\base\ErrorException' with message 'Cannot redeclare m1701
04_015108_create_table_items::up()'

in C:\xampp\htdocs\inventory\migrations\m170104_015108_create_table_items.php:20


Stack trace:
#0 [internal function]: yii\base\ErrorHandler->handleFatalError()
#1 {main}

c:\xampp\htdocs\inventory>yii migrate
Yii Migration Tool (based on Yii v2.0.10)

Total 4 new migrations to be applied:
        m170104_015108_create_table_items_old
        m170104_015212_create_table_transaction_types
        m170104_020833_create_table_transactions
        m170104_020933_create_table_transaction_details

Apply the above migrations? (yes|no) [no]:yes
*** applying m170104_015108_create_table_items_old
PHP Compile Error 'yii\base\ErrorException' with message 'Cannot redeclare m1701
04_015108_create_table_items::up()'

in C:\xampp\htdocs\inventory\migrations\m170104_015108_create_table_items_old.ph
p:20

Stack trace:
#0 [internal function]: yii\base\ErrorHandler->handleFatalError()
#1 {main}

c:\xampp\htdocs\inventory>yii migrate
Yii Migration Tool (based on Yii v2.0.10)

Total 4 new migrations to be applied:
        m151205_033021_create_items_table
        m151205_033540_create_transaction_types_table
        m151205_034210_create_transactions
        m151205_034216_create_transaction_details

Apply the above migrations? (yes|no) [no]:yes
*** applying m151205_033021_create_items_table
    > create table items ...Exception 'yii\db\Exception' with message 'SQLSTATE[
42S01]: Base table or view already exists: 1050 Table 'items' already exists
The SQL being executed was: CREATE TABLE `items` (
        `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
        `code` varchar(255) NOT NULL,
        `name` varchar(255) NOT NULL,
        `quantity` int(11) DEFAULT 0,
        `remarks` varchar(255)
)'

in C:\xampp\htdocs\inventory\vendor\yiisoft\yii2\db\Schema.php:631

Error Info:
Array
(
    [0] => 42S01
    [1] => 1050
    [2] => Table 'items' already exists
)

Stack trace:
#0 C:\xampp\htdocs\inventory\vendor\yiisoft\yii2\db\Command.php(854): yii\db\Sch
ema->convertException(Object(PDOException), 'CREATE TABLE `i...')
#1 C:\xampp\htdocs\inventory\vendor\yiisoft\yii2\db\Migration.php(261): yii\db\C
ommand->execute()
#2 C:\xampp\htdocs\inventory\migrations\m151205_033021_create_items_table.php(16
): yii\db\Migration->createTable('items', Array)
#3 C:\xampp\htdocs\inventory\vendor\yiisoft\yii2\console\controllers\BaseMigrate
Controller.php(651): m151205_033021_create_items_table->up()
#4 C:\xampp\htdocs\inventory\vendor\yiisoft\yii2\console\controllers\BaseMigrate
Controller.php(163): yii\console\controllers\BaseMigrateController->migrateUp('m
151205_033021_...')
#5 [internal function]: yii\console\controllers\BaseMigrateController->actionUp(
0)
#6 C:\xampp\htdocs\inventory\vendor\yiisoft\yii2\base\InlineAction.php(55): call
_user_func_array(Array, Array)
#7 C:\xampp\htdocs\inventory\vendor\yiisoft\yii2\base\Controller.php(154): yii\b
ase\InlineAction->runWithParams(Array)
#8 C:\xampp\htdocs\inventory\vendor\yiisoft\yii2\console\Controller.php(128): yi
i\base\Controller->runAction('', Array)
#9 C:\xampp\htdocs\inventory\vendor\yiisoft\yii2\base\Module.php(454): yii\conso
le\Controller->runAction('', Array)
#10 C:\xampp\htdocs\inventory\vendor\yiisoft\yii2\console\Application.php(180):
yii\base\Module->runAction('migrate', Array)
#11 C:\xampp\htdocs\inventory\vendor\yiisoft\yii2\console\Application.php(147):
yii\console\Application->runAction('migrate', Array)
#12 C:\xampp\htdocs\inventory\vendor\yiisoft\yii2\base\Application.php(375): yii
\console\Application->handleRequest(Object(yii\console\Request))
#13 C:\xampp\htdocs\inventory\yii(20): yii\base\Application->run()
#14 {main}

c:\xampp\htdocs\inventory>yii migrate
Yii Migration Tool (based on Yii v2.0.10)

Creating migration history table "migration"...Done.
Total 4 new migrations to be applied:
        m151205_033021_create_items_table
        m151205_033540_create_transaction_types_table
        m151205_034210_create_transactions
        m151205_034216_create_transaction_details

Apply the above migrations? (yes|no) [no]:yes
*** applying m151205_033021_create_items_table
    > create table items ... done (time: 0.193s)
*** applied m151205_033021_create_items_table (time: 0.242s)

*** applying m151205_033540_create_transaction_types_table
    > create table transaction_types ... done (time: 0.168s)
    > insert into transaction_types ... done (time: 0.128s)
    > insert into transaction_types ... done (time: 0.011s)
*** applied m151205_033540_create_transaction_types_table (time: 0.349s)

*** applying m151205_034210_create_transactions
    > create table transactions ... done (time: 0.143s)
    > add foreign key fk_transactions_types: transactions (type_id) references t
ransaction_types (id) ... done (time: 0.437s)
*** applied m151205_034210_create_transactions (time: 0.628s)

*** applying m151205_034216_create_transaction_details
    > create table transaction_details ... done (time: 0.234s)
    > add foreign key fk_transaction_details_transactions: transaction_details (
trans_id) references transactions (id) ... done (time: 0.553s)
    > add foreign key fk_transaction_details_items: transaction_details (item_id
) references items (id) ... done (time: 0.576s)
*** applied m151205_034216_create_transaction_details (time: 1.415s)


4 migrations were applied.

Migrated up successfully.

c:\xampp\htdocs\inventory>


p/s: credit to http://pojokprogrammer.net/content/aplikasi-persediaan-barang-sistem-inventory-menggunakan-yii2-part-2 for the awesome tutorial~

Comments

Popular posts from this blog

Temuduga Pegawai Teknologi Maklumat F41

Assalammualaikum and salam sejahtera uols.. Haish... lama benauu la tak update kan.. Bz..bz dengan kerja hakiki...bisnes part-time ni plak sejak pindah Kedah akak tak fokus sangat.. Dulu masa pjj ngan hubby and baru anak sorg ada la jugak masa nak berbisnes bagai.. Sekarang ni memang tak berapa nak pulun pasai bila balik rumah je sibuk nak uruskan rumahtangga and bebudak dua org tu.. Hokeh,,takmau cakap banyak cuma akak nak habaq kalo bebudak iT yang dah lama grad especially tahun 2010,2011 and so on  mesti tertunggu2 panggilan temuduga F41 khen khen khen.. Yelah mcm akak ni grad tahun 2011, interview F41 yang pertama kalinya dipanggil 2 tahun selepas itu iaitu 2013!..Lama giler nak tunggu sesuatu panggilan interview sekarang ni jika nak dibandingkan masa akak lepas sijil & diploma (tahun 2006-2009) bertalu2 surat panggilan interview sampai ke peti surat rumah.. Jadi sesiapa yang sekarang ni berjaya dipanggil temuduga as Pegawai Teknologi Maklumat (F41) sepatutnya kita semua b

Sharing is Caring || Breast Pump Review - Autumnz Marvel Single Electric Breast Pump

Salam.. selamat pagi.......... Hari ni I nak share something dgn pelanggan2 Blossom Lisha Shop mahupun yang bukan pelanggan.. yang search2 Google lalu terjumpa blog ni..ahaks.. Actually, I dah beli lama dah..kalo tak silap Ogos 2012.. Start pakai pam ni  lepas bersalin baby bulan Oktober 2012.. kiranya dah hampir 11 bulan la guna pam ni. So, I nak share experience I dengan sayang2 semua.. Masa nak beli pam, I try nak cari yang ringan, mudah nak handle, takmau bunyi kuat2, within budget dan yg tak bergantung electric supply all the time.. So, pada masa I tengah mencari2 tu, kalo bleh I nak Medela Swing..heeee... Kebetulan, Autumz baru je keluarkan produk baru beliau iaitu Autumnz Marvel Single Electric Breast Pump. Autumz pun keluarkan untuk double pump jugak iaitu Ultimate Convertible Double Electric/Manual Breast Pump. Masa beli tu I tak terpikir nak cari yang double pump coz I nak yang ringan and comel2 je. So bila hubby I tengok yang  Autumnz Marvel Single Electric Breast Pump pun

Sharing is Caring || Breast Pump Review - Medela Freestyle

Assalammualaikum gaisss!!!!! Lamanya akak tak sharing2 cerita kat sini.. Yelah sejak ber'anak' dua ni segala jenis objek aktiviti terbatas sangat2..Sapa-sapa yang pernah baca entry kat bawah ni mesti ingat akak pernah 'berhutang' (19 Mei 2014) nak review or story mory pasai double breast pump kan..hewhewhew.. ---> dah lebih setahun baru nak cerita, basi dah la dollllll heheh.. tp takpa akak nak ceritaaaaa jugakkkk~~ http://blossomlishashop.blogspot.my/2013/09/sharing-is-caring-breast-pump-review.html akak mintak maaf sangat2 la pasai takdan nak taip cerita bagai naa pasai dalam dok kalut dengan kerja, berjauhan dengan sang suami, bisnes kecik2 ni and struggle pam susu utk anak yg sulung tu tetiba dalam tak sedar 'termengandung' pulakkk =p... Lepaih dah termengandung tu...(anak sulung masa tu 1 tahun 6 bulan),  rezeki yang akak dok tunggu2 selama 3 tahun iaitu nak pindah dari Putrajaya ke Sungai Petani Kedah termakbul.. Alhamdulillah rezeki anak org kata