SlideShare une entreprise Scribd logo
1  sur  15
Taming data migrations
with Doctrine entities
and tons of enthusiasm
Petr Bechyně
Pehapkari.cz
31. 5. 2017
Problem
• keep some necessary data in database up-to-date
• typically
• enumerations
• users like administrator or content manager
• using PhpStorm “refactor this” (or “find usages”) will not affect
the sql commands
• your sql files may stop working after you change some
insert/update sql commands after certain development is
done
Solution
• do it manually
• write your own doctrine:migrations (same
problems as manual inserts, plus a risk of
breaking table structure migrations)
• use Doctrine/fixtures (--append just duplicates
the content)
• any other ideas?
Run away!
Hide!
Pretend you can’t see anything wrong.
Better use
DataApplier!
Doctrine DataApplier
• Repository: https://github.com/tuscanicz/doctrine-data-applier
• Symfony bundle
• Version: 0.9.1
• Tested in production
• MySQL
• Oracle
• Under development
What does it do?
• DataAppliers store your data using Doctrine
entities in your app
• detached
• no primary keys, just data
• see an example from our app
What does it do?
• running bin/console data:apply will synchronise
those entities with data in database
• won’t affect other data in same table (that were
inserted before or later by users or data imports)
• will insert new data, update them or even delete
(hope you backup regularly :-)
How does it work?
• Merges all the entities into one bundle and one
by one, compares them with database contents
and decides to persist new or merge or remove
the persisted entities.
• Cannot use primary keys, so you have to decide
what is your DataApplierIdentifier column (or
columns)
DataApplierIdentifier
• Annotation of Doctrine entity property
• We have no National ID number / ID card etc
id name surname city salary
1 Roman Tychka Brno 5000
2 Stojan Jakotych Podgorica 23000
3 Jane Brown London 3300
4 John Carter NY 1500
Primary key DataApplierIdentifier
DataApplierIdentifier
• DataApplierProcessor decides to take an action by
comparing these columns
id name surname city salary
1 Roman Tychka Brno 5000
2 Stojan Jakotych Podgorica 23000
3 Jane Brown London 3300
4 John Carter NY 1500
Primary key DataApplierIdentifier
Let’s try it…
That’s all folks!
Petr Bechyně
github.com/tuscanicz
mail@petrbechyne.com

Contenu connexe

Tendances

Building Windows Phone Database App Using MVVM Pattern
Building Windows Phone Database App Using MVVM PatternBuilding Windows Phone Database App Using MVVM Pattern
Building Windows Phone Database App Using MVVM PatternFiyaz Hasan
 
Stricter: ESlint for projects
Stricter: ESlint for projectsStricter: ESlint for projects
Stricter: ESlint for projectsAlexey Shpakov
 
IRE2014 Filtering Tweets Related to an entity
IRE2014 Filtering Tweets Related to an entityIRE2014 Filtering Tweets Related to an entity
IRE2014 Filtering Tweets Related to an entitykartik179
 
Layers, ports and adapters
Layers, ports and adaptersLayers, ports and adapters
Layers, ports and adaptersMatthias Noback
 
TXDHC OpenRefine Training
TXDHC OpenRefine TrainingTXDHC OpenRefine Training
TXDHC OpenRefine TrainingLiz Grumbach
 
A testing strategy for hexagonal applications
A testing strategy for hexagonal applicationsA testing strategy for hexagonal applications
A testing strategy for hexagonal applicationsMatthias Noback
 
SQL Tips + Tricks for Developers
SQL Tips + Tricks for DevelopersSQL Tips + Tricks for Developers
SQL Tips + Tricks for DevelopersVictorSzoltysek
 
Advanced web application architecture - PHP Barcelona
Advanced web application architecture  - PHP BarcelonaAdvanced web application architecture  - PHP Barcelona
Advanced web application architecture - PHP BarcelonaMatthias Noback
 
The SAM Pattern: State Machines and Computation
The SAM Pattern: State Machines and ComputationThe SAM Pattern: State Machines and Computation
The SAM Pattern: State Machines and ComputationJean-Jacques Dubray
 
Advanced web application architecture Way2Web
Advanced web application architecture Way2WebAdvanced web application architecture Way2Web
Advanced web application architecture Way2WebMatthias Noback
 
Hexagonal Symfony - SymfonyCon Amsterdam 2019
Hexagonal Symfony - SymfonyCon Amsterdam 2019Hexagonal Symfony - SymfonyCon Amsterdam 2019
Hexagonal Symfony - SymfonyCon Amsterdam 2019Matthias Noback
 

Tendances (14)

Building Windows Phone Database App Using MVVM Pattern
Building Windows Phone Database App Using MVVM PatternBuilding Windows Phone Database App Using MVVM Pattern
Building Windows Phone Database App Using MVVM Pattern
 
Stricter: ESlint for projects
Stricter: ESlint for projectsStricter: ESlint for projects
Stricter: ESlint for projects
 
IRE2014 Filtering Tweets Related to an entity
IRE2014 Filtering Tweets Related to an entityIRE2014 Filtering Tweets Related to an entity
IRE2014 Filtering Tweets Related to an entity
 
Layers, ports and adapters
Layers, ports and adaptersLayers, ports and adapters
Layers, ports and adapters
 
TXDHC OpenRefine Training
TXDHC OpenRefine TrainingTXDHC OpenRefine Training
TXDHC OpenRefine Training
 
A testing strategy for hexagonal applications
A testing strategy for hexagonal applicationsA testing strategy for hexagonal applications
A testing strategy for hexagonal applications
 
SQL Tips + Tricks for Developers
SQL Tips + Tricks for DevelopersSQL Tips + Tricks for Developers
SQL Tips + Tricks for Developers
 
Advanced web application architecture - PHP Barcelona
Advanced web application architecture  - PHP BarcelonaAdvanced web application architecture  - PHP Barcelona
Advanced web application architecture - PHP Barcelona
 
SQL injection
SQL injectionSQL injection
SQL injection
 
The SAM Pattern: State Machines and Computation
The SAM Pattern: State Machines and ComputationThe SAM Pattern: State Machines and Computation
The SAM Pattern: State Machines and Computation
 
Advanced web application architecture Way2Web
Advanced web application architecture Way2WebAdvanced web application architecture Way2Web
Advanced web application architecture Way2Web
 
What is JDBC
What is JDBCWhat is JDBC
What is JDBC
 
Hexagonal Symfony - SymfonyCon Amsterdam 2019
Hexagonal Symfony - SymfonyCon Amsterdam 2019Hexagonal Symfony - SymfonyCon Amsterdam 2019
Hexagonal Symfony - SymfonyCon Amsterdam 2019
 
Java ug
Java ugJava ug
Java ug
 

Similaire à Doctrine Data migrations | May 2017

XPages and jQuery DataTables: Simplifying View Creation while Maximizing Func...
XPages and jQuery DataTables: Simplifying View Creation while Maximizing Func...XPages and jQuery DataTables: Simplifying View Creation while Maximizing Func...
XPages and jQuery DataTables: Simplifying View Creation while Maximizing Func...Teamstudio
 
How Clean is your Database? Data Scrubbing for all Skill Sets
How Clean is your Database? Data Scrubbing for all Skill SetsHow Clean is your Database? Data Scrubbing for all Skill Sets
How Clean is your Database? Data Scrubbing for all Skill SetsChad Petrovay
 
Data Ingestion Engine
Data Ingestion EngineData Ingestion Engine
Data Ingestion EngineAdam Doyle
 
MWLUG 2016 : AD117 : Xpages & jQuery DataTables
MWLUG 2016 : AD117 : Xpages & jQuery DataTablesMWLUG 2016 : AD117 : Xpages & jQuery DataTables
MWLUG 2016 : AD117 : Xpages & jQuery DataTablesMichael Smith
 
php databse handling
php databse handlingphp databse handling
php databse handlingkunj desai
 
Waiting too long for Excel's VLOOKUP? Use SQLite for simple data analysis!
Waiting too long for Excel's VLOOKUP? Use SQLite for simple data analysis!Waiting too long for Excel's VLOOKUP? Use SQLite for simple data analysis!
Waiting too long for Excel's VLOOKUP? Use SQLite for simple data analysis!Amanda Lam
 
Testing database content with DBUnit. My experience.
Testing database content with DBUnit. My experience.Testing database content with DBUnit. My experience.
Testing database content with DBUnit. My experience.Serhii Kartashov
 
Building a Testable Data Access Layer
Building a Testable Data Access LayerBuilding a Testable Data Access Layer
Building a Testable Data Access LayerTodd Anglin
 
The Missing Link: Metadata Conversion Workflows for Everyone
The Missing Link: Metadata Conversion Workflows for EveryoneThe Missing Link: Metadata Conversion Workflows for Everyone
The Missing Link: Metadata Conversion Workflows for EveryoneAndrea Payant
 
Python programming
Python programmingPython programming
Python programmingsirikeshava
 
Michael Bayer Introduction to SQLAlchemy @ Postgres Open
Michael Bayer Introduction to SQLAlchemy @ Postgres OpenMichael Bayer Introduction to SQLAlchemy @ Postgres Open
Michael Bayer Introduction to SQLAlchemy @ Postgres OpenPostgresOpen
 
7 Database Mistakes YOU Are Making -- Linuxfest Northwest 2019
7 Database Mistakes YOU Are Making -- Linuxfest Northwest 20197 Database Mistakes YOU Are Making -- Linuxfest Northwest 2019
7 Database Mistakes YOU Are Making -- Linuxfest Northwest 2019Dave Stokes
 
Secrets of highly_avail_oltp_archs
Secrets of highly_avail_oltp_archsSecrets of highly_avail_oltp_archs
Secrets of highly_avail_oltp_archsTarik Essawi
 

Similaire à Doctrine Data migrations | May 2017 (20)

XPages and jQuery DataTables: Simplifying View Creation while Maximizing Func...
XPages and jQuery DataTables: Simplifying View Creation while Maximizing Func...XPages and jQuery DataTables: Simplifying View Creation while Maximizing Func...
XPages and jQuery DataTables: Simplifying View Creation while Maximizing Func...
 
Test data generation
Test data generationTest data generation
Test data generation
 
How Clean is your Database? Data Scrubbing for all Skill Sets
How Clean is your Database? Data Scrubbing for all Skill SetsHow Clean is your Database? Data Scrubbing for all Skill Sets
How Clean is your Database? Data Scrubbing for all Skill Sets
 
Data Ingestion Engine
Data Ingestion EngineData Ingestion Engine
Data Ingestion Engine
 
MWLUG 2016 : AD117 : Xpages & jQuery DataTables
MWLUG 2016 : AD117 : Xpages & jQuery DataTablesMWLUG 2016 : AD117 : Xpages & jQuery DataTables
MWLUG 2016 : AD117 : Xpages & jQuery DataTables
 
php databse handling
php databse handlingphp databse handling
php databse handling
 
Taming the shrew Power BI
Taming the shrew Power BITaming the shrew Power BI
Taming the shrew Power BI
 
Waiting too long for Excel's VLOOKUP? Use SQLite for simple data analysis!
Waiting too long for Excel's VLOOKUP? Use SQLite for simple data analysis!Waiting too long for Excel's VLOOKUP? Use SQLite for simple data analysis!
Waiting too long for Excel's VLOOKUP? Use SQLite for simple data analysis!
 
Testing database content with DBUnit. My experience.
Testing database content with DBUnit. My experience.Testing database content with DBUnit. My experience.
Testing database content with DBUnit. My experience.
 
Building a Testable Data Access Layer
Building a Testable Data Access LayerBuilding a Testable Data Access Layer
Building a Testable Data Access Layer
 
The Missing Link: Metadata Conversion Workflows for Everyone
The Missing Link: Metadata Conversion Workflows for EveryoneThe Missing Link: Metadata Conversion Workflows for Everyone
The Missing Link: Metadata Conversion Workflows for Everyone
 
Intro_2.ppt
Intro_2.pptIntro_2.ppt
Intro_2.ppt
 
Intro.ppt
Intro.pptIntro.ppt
Intro.ppt
 
Intro.ppt
Intro.pptIntro.ppt
Intro.ppt
 
Python programming
Python programmingPython programming
Python programming
 
Michael Bayer Introduction to SQLAlchemy @ Postgres Open
Michael Bayer Introduction to SQLAlchemy @ Postgres OpenMichael Bayer Introduction to SQLAlchemy @ Postgres Open
Michael Bayer Introduction to SQLAlchemy @ Postgres Open
 
Ado
AdoAdo
Ado
 
7 Database Mistakes YOU Are Making -- Linuxfest Northwest 2019
7 Database Mistakes YOU Are Making -- Linuxfest Northwest 20197 Database Mistakes YOU Are Making -- Linuxfest Northwest 2019
7 Database Mistakes YOU Are Making -- Linuxfest Northwest 2019
 
Secrets of highly_avail_oltp_archs
Secrets of highly_avail_oltp_archsSecrets of highly_avail_oltp_archs
Secrets of highly_avail_oltp_archs
 
PHP - Introduction to PHP Date and Time Functions
PHP -  Introduction to  PHP Date and Time FunctionsPHP -  Introduction to  PHP Date and Time Functions
PHP - Introduction to PHP Date and Time Functions
 

Plus de Petr Bechyně

Glami - jak řešíme performance, aneb jak neshodit web TV reklamou
Glami - jak řešíme performance, aneb jak neshodit web TV reklamouGlami - jak řešíme performance, aneb jak neshodit web TV reklamou
Glami - jak řešíme performance, aneb jak neshodit web TV reklamouPetr Bechyně
 
Adam Szabo: Jak jsme v Driveto zlepšovali konverze
Adam Szabo: Jak jsme v Driveto zlepšovali konverzeAdam Szabo: Jak jsme v Driveto zlepšovali konverze
Adam Szabo: Jak jsme v Driveto zlepšovali konverzePetr Bechyně
 
Péhápkaři - Píšeme čitelný a testovatelný kód #5 by Driveto dev team
Péhápkaři - Píšeme čitelný a testovatelný kód #5 by Driveto dev teamPéhápkaři - Píšeme čitelný a testovatelný kód #5 by Driveto dev team
Péhápkaři - Píšeme čitelný a testovatelný kód #5 by Driveto dev teamPetr Bechyně
 
Péhápkaři - Píšeme čitelný kód #4 by Petr Bechyně, Driveto
Péhápkaři - Píšeme čitelný kód #4 by Petr Bechyně, DrivetoPéhápkaři - Píšeme čitelný kód #4 by Petr Bechyně, Driveto
Péhápkaři - Píšeme čitelný kód #4 by Petr Bechyně, DrivetoPetr Bechyně
 
SEO Restart 2015 - Collabim
SEO Restart 2015 - CollabimSEO Restart 2015 - Collabim
SEO Restart 2015 - CollabimPetr Bechyně
 
Péhápkaři - Píšeme čitelný kód #3 by Driveto
Péhápkaři - Píšeme čitelný kód #3 by DrivetoPéhápkaři - Píšeme čitelný kód #3 by Driveto
Péhápkaři - Píšeme čitelný kód #3 by DrivetoPetr Bechyně
 
Péhápkaři - Píšeme čitelný kód #2 by Petr Bechyně, Driveto
Péhápkaři - Píšeme čitelný kód #2 by Petr Bechyně, DrivetoPéhápkaři - Píšeme čitelný kód #2 by Petr Bechyně, Driveto
Péhápkaři - Píšeme čitelný kód #2 by Petr Bechyně, DrivetoPetr Bechyně
 
Péhápkaři - Píšeme čitelný kód #1 by Petr Bechyně, Driveto
Péhápkaři - Píšeme čitelný kód #1 by Petr Bechyně, DrivetoPéhápkaři - Píšeme čitelný kód #1 by Petr Bechyně, Driveto
Péhápkaři - Píšeme čitelný kód #1 by Petr Bechyně, DrivetoPetr Bechyně
 
Svlékněte konkurenci donaha: Jiří Koutný, Collabim
Svlékněte konkurenci donaha: Jiří Koutný, CollabimSvlékněte konkurenci donaha: Jiří Koutný, Collabim
Svlékněte konkurenci donaha: Jiří Koutný, CollabimPetr Bechyně
 
Pionýři Digitálu #2 - Klíčová analýza slov
Pionýři Digitálu #2 - Klíčová analýza slovPionýři Digitálu #2 - Klíčová analýza slov
Pionýři Digitálu #2 - Klíčová analýza slovPetr Bechyně
 

Plus de Petr Bechyně (10)

Glami - jak řešíme performance, aneb jak neshodit web TV reklamou
Glami - jak řešíme performance, aneb jak neshodit web TV reklamouGlami - jak řešíme performance, aneb jak neshodit web TV reklamou
Glami - jak řešíme performance, aneb jak neshodit web TV reklamou
 
Adam Szabo: Jak jsme v Driveto zlepšovali konverze
Adam Szabo: Jak jsme v Driveto zlepšovali konverzeAdam Szabo: Jak jsme v Driveto zlepšovali konverze
Adam Szabo: Jak jsme v Driveto zlepšovali konverze
 
Péhápkaři - Píšeme čitelný a testovatelný kód #5 by Driveto dev team
Péhápkaři - Píšeme čitelný a testovatelný kód #5 by Driveto dev teamPéhápkaři - Píšeme čitelný a testovatelný kód #5 by Driveto dev team
Péhápkaři - Píšeme čitelný a testovatelný kód #5 by Driveto dev team
 
Péhápkaři - Píšeme čitelný kód #4 by Petr Bechyně, Driveto
Péhápkaři - Píšeme čitelný kód #4 by Petr Bechyně, DrivetoPéhápkaři - Píšeme čitelný kód #4 by Petr Bechyně, Driveto
Péhápkaři - Píšeme čitelný kód #4 by Petr Bechyně, Driveto
 
SEO Restart 2015 - Collabim
SEO Restart 2015 - CollabimSEO Restart 2015 - Collabim
SEO Restart 2015 - Collabim
 
Péhápkaři - Píšeme čitelný kód #3 by Driveto
Péhápkaři - Píšeme čitelný kód #3 by DrivetoPéhápkaři - Píšeme čitelný kód #3 by Driveto
Péhápkaři - Píšeme čitelný kód #3 by Driveto
 
Péhápkaři - Píšeme čitelný kód #2 by Petr Bechyně, Driveto
Péhápkaři - Píšeme čitelný kód #2 by Petr Bechyně, DrivetoPéhápkaři - Píšeme čitelný kód #2 by Petr Bechyně, Driveto
Péhápkaři - Píšeme čitelný kód #2 by Petr Bechyně, Driveto
 
Péhápkaři - Píšeme čitelný kód #1 by Petr Bechyně, Driveto
Péhápkaři - Píšeme čitelný kód #1 by Petr Bechyně, DrivetoPéhápkaři - Píšeme čitelný kód #1 by Petr Bechyně, Driveto
Péhápkaři - Píšeme čitelný kód #1 by Petr Bechyně, Driveto
 
Svlékněte konkurenci donaha: Jiří Koutný, Collabim
Svlékněte konkurenci donaha: Jiří Koutný, CollabimSvlékněte konkurenci donaha: Jiří Koutný, Collabim
Svlékněte konkurenci donaha: Jiří Koutný, Collabim
 
Pionýři Digitálu #2 - Klíčová analýza slov
Pionýři Digitálu #2 - Klíčová analýza slovPionýři Digitálu #2 - Klíčová analýza slov
Pionýři Digitálu #2 - Klíčová analýza slov
 

Dernier

RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝DelhiRS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhijennyeacort
 
Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 217djon017
 
Advanced Machine Learning for Business Professionals
Advanced Machine Learning for Business ProfessionalsAdvanced Machine Learning for Business Professionals
Advanced Machine Learning for Business ProfessionalsVICTOR MAESTRE RAMIREZ
 
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...ssuserf63bd7
 
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...Amil Baba Dawood bangali
 
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...Boston Institute of Analytics
 
Vision, Mission, Goals and Objectives ppt..pptx
Vision, Mission, Goals and Objectives ppt..pptxVision, Mission, Goals and Objectives ppt..pptx
Vision, Mission, Goals and Objectives ppt..pptxellehsormae
 
Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024Colleen Farrelly
 
Student profile product demonstration on grades, ability, well-being and mind...
Student profile product demonstration on grades, ability, well-being and mind...Student profile product demonstration on grades, ability, well-being and mind...
Student profile product demonstration on grades, ability, well-being and mind...Seán Kennedy
 
Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...
Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...
Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...Thomas Poetter
 
Multiple time frame trading analysis -brianshannon.pdf
Multiple time frame trading analysis -brianshannon.pdfMultiple time frame trading analysis -brianshannon.pdf
Multiple time frame trading analysis -brianshannon.pdfchwongval
 
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024thyngster
 
Real-Time AI Streaming - AI Max Princeton
Real-Time AI  Streaming - AI Max PrincetonReal-Time AI  Streaming - AI Max Princeton
Real-Time AI Streaming - AI Max PrincetonTimothy Spann
 
Semantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptxSemantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptxMike Bennett
 
DBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfDBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfJohn Sterrett
 
Top 5 Best Data Analytics Courses In Queens
Top 5 Best Data Analytics Courses In QueensTop 5 Best Data Analytics Courses In Queens
Top 5 Best Data Analytics Courses In Queensdataanalyticsqueen03
 
Heart Disease Classification Report: A Data Analysis Project
Heart Disease Classification Report: A Data Analysis ProjectHeart Disease Classification Report: A Data Analysis Project
Heart Disease Classification Report: A Data Analysis ProjectBoston Institute of Analytics
 
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理e4aez8ss
 
detection and classification of knee osteoarthritis.pptx
detection and classification of knee osteoarthritis.pptxdetection and classification of knee osteoarthritis.pptx
detection and classification of knee osteoarthritis.pptxAleenaJamil4
 

Dernier (20)

RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝DelhiRS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
 
Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2
 
Advanced Machine Learning for Business Professionals
Advanced Machine Learning for Business ProfessionalsAdvanced Machine Learning for Business Professionals
Advanced Machine Learning for Business Professionals
 
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...
 
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
 
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...
 
Vision, Mission, Goals and Objectives ppt..pptx
Vision, Mission, Goals and Objectives ppt..pptxVision, Mission, Goals and Objectives ppt..pptx
Vision, Mission, Goals and Objectives ppt..pptx
 
Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024
 
Student profile product demonstration on grades, ability, well-being and mind...
Student profile product demonstration on grades, ability, well-being and mind...Student profile product demonstration on grades, ability, well-being and mind...
Student profile product demonstration on grades, ability, well-being and mind...
 
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
 
Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...
Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...
Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...
 
Multiple time frame trading analysis -brianshannon.pdf
Multiple time frame trading analysis -brianshannon.pdfMultiple time frame trading analysis -brianshannon.pdf
Multiple time frame trading analysis -brianshannon.pdf
 
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
 
Real-Time AI Streaming - AI Max Princeton
Real-Time AI  Streaming - AI Max PrincetonReal-Time AI  Streaming - AI Max Princeton
Real-Time AI Streaming - AI Max Princeton
 
Semantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptxSemantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptx
 
DBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfDBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdf
 
Top 5 Best Data Analytics Courses In Queens
Top 5 Best Data Analytics Courses In QueensTop 5 Best Data Analytics Courses In Queens
Top 5 Best Data Analytics Courses In Queens
 
Heart Disease Classification Report: A Data Analysis Project
Heart Disease Classification Report: A Data Analysis ProjectHeart Disease Classification Report: A Data Analysis Project
Heart Disease Classification Report: A Data Analysis Project
 
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
 
detection and classification of knee osteoarthritis.pptx
detection and classification of knee osteoarthritis.pptxdetection and classification of knee osteoarthritis.pptx
detection and classification of knee osteoarthritis.pptx
 

Doctrine Data migrations | May 2017

  • 1. Taming data migrations with Doctrine entities and tons of enthusiasm Petr Bechyně Pehapkari.cz 31. 5. 2017
  • 2. Problem • keep some necessary data in database up-to-date • typically • enumerations • users like administrator or content manager • using PhpStorm “refactor this” (or “find usages”) will not affect the sql commands • your sql files may stop working after you change some insert/update sql commands after certain development is done
  • 3. Solution • do it manually • write your own doctrine:migrations (same problems as manual inserts, plus a risk of breaking table structure migrations) • use Doctrine/fixtures (--append just duplicates the content) • any other ideas?
  • 6. Pretend you can’t see anything wrong.
  • 8. Doctrine DataApplier • Repository: https://github.com/tuscanicz/doctrine-data-applier • Symfony bundle • Version: 0.9.1 • Tested in production • MySQL • Oracle • Under development
  • 9. What does it do? • DataAppliers store your data using Doctrine entities in your app • detached • no primary keys, just data • see an example from our app
  • 10. What does it do? • running bin/console data:apply will synchronise those entities with data in database • won’t affect other data in same table (that were inserted before or later by users or data imports) • will insert new data, update them or even delete (hope you backup regularly :-)
  • 11. How does it work? • Merges all the entities into one bundle and one by one, compares them with database contents and decides to persist new or merge or remove the persisted entities. • Cannot use primary keys, so you have to decide what is your DataApplierIdentifier column (or columns)
  • 12. DataApplierIdentifier • Annotation of Doctrine entity property • We have no National ID number / ID card etc id name surname city salary 1 Roman Tychka Brno 5000 2 Stojan Jakotych Podgorica 23000 3 Jane Brown London 3300 4 John Carter NY 1500 Primary key DataApplierIdentifier
  • 13. DataApplierIdentifier • DataApplierProcessor decides to take an action by comparing these columns id name surname city salary 1 Roman Tychka Brno 5000 2 Stojan Jakotych Podgorica 23000 3 Jane Brown London 3300 4 John Carter NY 1500 Primary key DataApplierIdentifier
  • 15. That’s all folks! Petr Bechyně github.com/tuscanicz mail@petrbechyne.com