Upload
atwix
View
91
Download
3
Tags:
Embed Size (px)
Citation preview
Data ConsistencyAdmin Panel vs Migration scripts
About me
✓ 8 years of web development
✓ 4 years of magento development
✓ CTO in Speroteck company
Context
✓ Web development✓ Magento✓ Team development (6m+)✓ Quality (automation)✓ Project (Not Product) development ✓ Enterprise level in terms of complexity
What is “Application”?
It’s a Code which receives Input Data, produces Output Result and executed on particular Environment.
Development (Team) Problems
Code Consistency - GITEnvironment Consistency - VagrantData Consistency - ?
What is Data Consistency?
Physical meaning. Process of keeping information uniform as it moves across a network and between various applications.
Semantic meaning. Process of keeping information expected as it moves inside of the application.
Data and application context.
Significant data.✓ Configuration data✓ Application data✓ Input data
What’s the problem?
1. How to store and share data changes between developers?
2. How to migrate data changes between application instances?
3. How to bind Code Revision and Application Data?
Use Case #1
Given: I am as a Manager of music store
should see 20 websites of the Artists I work with
and each Artist should have 4 supported languages
and Catalogs should be different for each Artist
When: I go to Admin PanelThen: I should be able to manage them
Use Case #2
Given: I am as a Manager of music store
When: I go to website of Artist AThen: I should see branded design
and see custom pages “Home”, “About Artist”, “Concerts”, “Recent Hits”, “Contacts”
and see branded banner in the Header
and see social links of Artist A
Use Case #3
Given: I am as a Customer of music store
When: I am on the Product B Page of Artist A website
Then: I should be able to listen samples
and buy artist’s sign on the box and choose free present
and choose color of the T-shirt
and customize logo on the tea-cup
and see special promotions
Imagine this store
1. We will use Magento Enterprise2. Create 20 websites + 4 store views for
each website3. Create 20 root categories and assign each
for own website4. Add “complex” Product B to Artist A5. Set branded design
Reality strikes back
✓ We work in a Team✓ Data changes happens very frequent✓ Client wants to see the results✓ QA needs stable data to write tests✓ . . .
Back to problems
How to Store and Share data changes between
developers?
Ways to share data changes
✓ Share database✓ $ mysqldump✓ Migration scripts
Brutal Bad guys use Shared Database
Bad guys use $ mysqldump
$ mysqldump
− Easy to use− Cheap changes
+ Manual work+ Hard to track
changes
$ mysqldump workflow
1. Download recent database2. Make data changes3. Upload database and mark it as recent
Who use Migration scripts?
+ Consistent data+ Easy to track
changes
− Hard to use− Conflicts between
versions*− No uninstall
scripts*− No API for
complex data*
The holy grail of the development
Deploy application on local environment with 1 click, make changes and push them to the Development Center
Development Center
Development Center - infrastructure which receives changes as an input and produce stable application build as an output
Build. Gather Together.
1. Prepare Environment2. Prepare Code3. Load Data 4. Configure Application5. Verify Functionality6. Generate Artifacts
Best practices of migrations usage
1. Create Global package2. Use to configure store3. Use “data” and “sql” folders right4. Write own API to export/import data5. Use database profiler to verify data6. Be ready to stop usage of migrations
Global package
✓ Configure store✓ Add application data✓ Small code changes,
patches etc.✓ Global elements and
parts Example “social links”
Use to configure store
Use possibility to configure store with the help of install scripts. Once it will save your ass.
Use “data” and “sql” folders right
“Data” folder is used to add content data changes and configuration changes
“Sql” folder is used to add database changes
Use “data” and “sql” folders right
Move to Setup scripts as much as possible.
Write own API to export/import data
✓ Don’t afraid to write something like “Email templates importer”
✓ Use Magento API✓ Don’t afraid raw SQL✓ Use ready to use solutions.
Example Cms Installer
Use database profiler to verify data
Be ready to throw migrations away
The End