32
Data Consistency Admin Panel vs Migration scripts

Владимир Дубина - Meet Magento Ukraine - Data consistency

  • Upload
    atwix

  • View
    91

  • Download
    3

Embed Size (px)

Citation preview

Page 1: Владимир Дубина - Meet Magento Ukraine - Data consistency

Data ConsistencyAdmin Panel vs Migration scripts

Page 2: Владимир Дубина - Meet Magento Ukraine - Data consistency

About me

✓ 8 years of web development

✓ 4 years of magento development

✓ CTO in Speroteck company

Page 3: Владимир Дубина - Meet Magento Ukraine - Data consistency

Context

✓ Web development✓ Magento✓ Team development (6m+)✓ Quality (automation)✓ Project (Not Product) development ✓ Enterprise level in terms of complexity

Page 4: Владимир Дубина - Meet Magento Ukraine - Data consistency

What is “Application”?

It’s a Code which receives Input Data, produces Output Result and executed on particular Environment.

Page 5: Владимир Дубина - Meet Magento Ukraine - Data consistency

Development (Team) Problems

Code Consistency - GITEnvironment Consistency - VagrantData Consistency - ?

Page 6: Владимир Дубина - Meet Magento Ukraine - Data 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.

Page 7: Владимир Дубина - Meet Magento Ukraine - Data consistency

Data and application context.

Significant data.✓ Configuration data✓ Application data✓ Input data

Page 8: Владимир Дубина - Meet Magento Ukraine - Data consistency

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?

Page 9: Владимир Дубина - Meet Magento Ukraine - Data consistency

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

Page 10: Владимир Дубина - Meet Magento Ukraine - Data consistency

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

Page 11: Владимир Дубина - Meet Magento Ukraine - Data consistency

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

Page 12: Владимир Дубина - Meet Magento Ukraine - Data consistency

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

Page 13: Владимир Дубина - Meet Magento Ukraine - Data consistency

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✓ . . .

Page 14: Владимир Дубина - Meet Magento Ukraine - Data consistency

Back to problems

How to Store and Share data changes between

developers?

Page 15: Владимир Дубина - Meet Magento Ukraine - Data consistency

Ways to share data changes

✓ Share database✓ $ mysqldump✓ Migration scripts

Page 16: Владимир Дубина - Meet Magento Ukraine - Data consistency

Brutal Bad guys use Shared Database

Page 17: Владимир Дубина - Meet Magento Ukraine - Data consistency

Bad guys use $ mysqldump

Page 18: Владимир Дубина - Meet Magento Ukraine - Data consistency

$ mysqldump

− Easy to use− Cheap changes

+ Manual work+ Hard to track

changes

Page 19: Владимир Дубина - Meet Magento Ukraine - Data consistency

$ mysqldump workflow

1. Download recent database2. Make data changes3. Upload database and mark it as recent

Page 20: Владимир Дубина - Meet Magento Ukraine - Data consistency

Who use Migration scripts?

+ Consistent data+ Easy to track

changes

− Hard to use− Conflicts between

versions*− No uninstall

scripts*− No API for

complex data*

Page 21: Владимир Дубина - Meet Magento Ukraine - Data consistency

The holy grail of the development

Deploy application on local environment with 1 click, make changes and push them to the Development Center

Page 22: Владимир Дубина - Meet Magento Ukraine - Data consistency

Development Center

Development Center - infrastructure which receives changes as an input and produce stable application build as an output

Page 23: Владимир Дубина - Meet Magento Ukraine - Data consistency

Build. Gather Together.

1. Prepare Environment2. Prepare Code3. Load Data 4. Configure Application5. Verify Functionality6. Generate Artifacts

Page 24: Владимир Дубина - Meet Magento Ukraine - Data consistency

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

Page 25: Владимир Дубина - Meet Magento Ukraine - Data consistency

Global package

✓ Configure store✓ Add application data✓ Small code changes,

patches etc.✓ Global elements and

parts Example “social links”

Page 26: Владимир Дубина - Meet Magento Ukraine - Data consistency

Use to configure store

Use possibility to configure store with the help of install scripts. Once it will save your ass.

Page 27: Владимир Дубина - Meet Magento Ukraine - Data consistency

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

Page 28: Владимир Дубина - Meet Magento Ukraine - Data consistency

Use “data” and “sql” folders right

Move to Setup scripts as much as possible.

Page 29: Владимир Дубина - Meet Magento Ukraine - Data consistency

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

Page 30: Владимир Дубина - Meet Magento Ukraine - Data consistency

Use database profiler to verify data

Page 31: Владимир Дубина - Meet Magento Ukraine - Data consistency

Be ready to throw migrations away

Page 32: Владимир Дубина - Meet Magento Ukraine - Data consistency

The End

[email protected]