======================================================================= HOW TO RUN THIS MIGRATION BY HAND ======================================================================= You are going to convert the old database to the shape the new application needs, one module at a time, through phpMyAdmin. You can stop after any module and come back next week. That is the whole point of doing it this way: the application blocks any page whose tables are not converted yet, so a half-finished migration is safe to leave. Where the files are: in the code: two db/import/ on the server: /migration/import/ ----------------------------------------------------------------------- 1. BEFORE YOU START ----------------------------------------------------------------------- a) TAKE A BACKUP. Some of these steps change data and nothing undoes them. b) RUN THE AUDIT FIRST and read its check 8: mysql -D < ../audit_bukanmain_before_migrate.sql > audit.txt Check 8 looks for a lookup table that is EMPTY. If it names one, STOP and ask -- converting with an empty lookup table silently wipes every reference to it, and there is no undo. The audit only reads; it changes nothing. c) IN phpMyAdmin, UNTICK "Allow the interruption of an import". It is on the Import tab. If it fires, phpMyAdmin reconnects halfway through a file and the safety settings are lost without telling you. d) NEVER switch on "continue on error", and never use `mysql --force`. Stopping at the first error is the main protection you have. e) TAKE THE OLD PHP APPLICATION OFFLINE, or at least stop people writing to it. In each file there is a moment between "this table is clean" and "the rules are locked in"; anything written in that moment is never checked. ----------------------------------------------------------------------- 2. THE ORDER ----------------------------------------------------------------------- Import ONE FILE AT A TIME, in this order. +---+--------------------------+----------------------------------------+ | # | What | Which files | +---+--------------------------+----------------------------------------+ | 1 | System | 00_system/01_system.sql | | 2 | Masters | all 7 in 10_master/ | | 3 | The module you want live | the files INDEX.md lists for that menu | | 4 | Repeat step 3 | as many modules as you want, any order | | 5 | The rest | all 4 in 90_no_menu/ | | 6 | Finish | zz_finalize/99_finalize.sql | +---+--------------------------+----------------------------------------+ You may stop after step 3 and continue another day. Steps 5 and 6 only matter when you intend to finish for good. *** A MODULE IS OFTEN MORE THAN ONE FILE. LOOK IT UP FIRST. *** 94 of the 249 menu links need more than one file from 30_transaction/ A page that shows records from another module needs that module's tables too, or it would render blank fields where names belong. INDEX.md, in this folder, lists every menu link and the files it needs. Find your menu there before you import. Quotation is the common example. It needs BOTH of these: 30_transaction/30_quotation.sql 30_transaction/39_creditceiling.sql Import only the first and the page still says "not migrated yet" -- and tells you the table it is waiting for. That is not a failed import. It is the application refusing to show you a page it cannot fill in. The order again, with every file name spelled out: STEP 1 -- the system file. Always first, no exceptions. 00_system/01_system.sql STEP 2 -- the masters, in 10_master/ All 7 of them, before any module. 10_masterdata.sql, 11_reference.sql, 12_principal.sql, 13_barang.sql, 14_vehicle.sql, 15_company.sql, 16_companyproject.sql STEP 3 -- the module files, in 30_transaction/ Any order, as many as you want. This is where you choose what goes live. CHECK INDEX.md -- most modules need one file, 94 of the 249 menus need two or more. 30_quotation.sql, 31_sampleorder.sql, 32_samplerequestimport.sql, 33_stocksample.sql, 34_labworkrequest.sql, 35_visitplan.sql, 36_companyproduct.sql, 37_complain.sql, 38_complaintosupplier.sql, 39_creditceiling.sql, 40_budgetandtarget.sql, 41_salesrebate.sql, 42_successstory.sql, 43_printlabel.sql, 44_document.sql, 45_generalaffairs.sql, 46_netsuite.sql STEP 4 -- only when you are finishing for good: the 4 files in 90_no_menu/ that have no page of their own. 91_hr.sql, 92_purchaseorder.sql, 93_potentialsales.sql, 94_news.sql STEP 5 -- last. It refuses to run until everything else is in. zz_finalize/99_finalize.sql ----------------------------------------------------------------------- 3. WHILE IT IS RUNNING ----------------------------------------------------------------------- Every file checks itself and stops if something is wrong. If you see a message like one of these, it is the file talking to you: "import 00_system/01_system.sql first" You skipped STEP 1. Do it, then carry on. "applied from a DIFFERENT version of this file" This database was converted using older files. Do NOT just run it again. Ask first. "MISSING foreign keys: barang.barang_SatuanID ..." Something did not take effect. The message names exactly what is missing and what to do about it. IF ANY FILE STOPS WITH AN ERROR, STOP EVERYTHING. Do not skip that file and carry on with the next one. Fix it, or ask. Note: phpMyAdmin's Import tab shows errors but not the "all fine" messages. Seeing only "N queries executed successfully" is normal. If you want to read the messages, paste the file into the SQL tab instead. ----------------------------------------------------------------------- 4. HOW FAR ALONG AM I? ----------------------------------------------------------------------- SELECT COUNT(*) FROM _migration_ledger; 632 means completely finished. Importing a file you already did is free. It skips what is done and takes a few seconds. So if you lose your place, just import it again -- you cannot do damage by repeating a file. ----------------------------------------------------------------------- 5. IF YOU HAVE A COMMAND LINE INSTEAD ----------------------------------------------------------------------- cd "two db/step" && ./run.sh --status what is applied cd "two db/step" && ./run.sh --group one module cd "two db/step" && ./run.sh --all everything Both paths write the same record, so you can mix them: import three modules through the browser and finish the rest from a shell. WHICH FILES DOES MY MENU NEED? -> INDEX.md, in this folder. Longer explanations of everything above -> README.md. Checksums to verify the files arrived intact -> MANIFEST.md.