SlideShare una empresa de Scribd logo
1 de 78
© 2019 Magento, Inc. Page | 1
Magento 2.3
Declarative Schema
© 2019 Magento, Inc.
.
Page | 2
Lead Developer at BORN Group
Atish Goswami
© 2019 Magento, Inc. Page | 3
Agenda
© 2019 Magento, Inc. Page | 4
Agenda
• What is Declarative Schema ?
• Declaring table schemes
• Updating existing table schemes
• New CLI commands and arguments
• Schema Rollback
© 2019 Magento, Inc. Page | 5
Not In Scope
© 2019 Magento, Inc. Page | 6
Not in Scope
• Applying Data Patches
• Patch Rollbacks
• Schema Patches (Trigger/Stored Procedures)
© 2019 Magento, Inc. Page | 7
What is Declarative
Schema ?
© 2019 Magento, Inc. Page | 8
Declarative Schema
• Newer way of handling Setup Script Operations
• Setup Scripts are still supported in 2.3.x versions (EOL unknown)
• Might be Backported to 2.2.x newer versions
• Declarative Schema and Setup Scripts don’t work together
• If developing backwards compatible modules use Setup Script
© 2019 Magento, Inc. Page | 9
Why Declarative Schema ?
© 2019 Magento, Inc. Page | 10
Issues with Setup Scripts
• Setup Scripts get complicated to manage overtime
• Module sequencing needs to be handled properly
• Confusing to manage Install vs Upgrade scripts
• Version number mishap happens
• No Rollbacks
© 2019 Magento, Inc. Page | 11
Will Declarative Schema
help ?
© 2019 Magento, Inc. Page | 12
Declarative Schema Offers
• Avoidance of missed/repeated SQL operations
• Installation testing using dry-run mode
• Performance optimization
• Support for rollbacks *
© 2019 Magento, Inc. Page | 13
Getting Started
© 2019 Magento, Inc. Page | 14
<module_root>/registration.php
© 2019 Magento, Inc. Page | 15
<module_root>/etc/module.xml
Note : Declarative Schema does not require version number
© 2019 Magento, Inc. Page | 16
<module_root>/etc/db_schema.xml
New xml file introduced by Declarative Schema
© 2019 Magento, Inc. Page | 17
Declaring a table
© 2019 Magento, Inc. Page | 18
© 2019 Magento, Inc. Page | 19
<table/> Attributes
• name
– Name of the table
– Required
• resource (default)
– Database connection to use for the operation
– Allowed values – default, sales, checkout
• engine (innodb)
– MySQL Table engine
– Allowed values – innodb, memory
© 2019 Magento, Inc. Page | 20
<table/> Attributes (Contd)
• comment (not comments added)
– Comment Relating the table
• charset (utf8)
– Charset for the table
• collation (utf8_general_ci)
– Collation to match the charset
• onCreate (empty)
– Helps trigger a task after the table is created
© 2019 Magento, Inc. Page | 21
Declaring integer columns
© 2019 Magento, Inc. Page | 22
<module_root>/etc/db_schema.xml
© 2019 Magento, Inc. Page | 23
<column/> Integer Attributes
• name
– Name of the column
– Required
• xsi:type
– Allowed Values – (tinyint, int, smallint, bigint, boolean)
– Required
• default (NULL)
– Provide default column value
– Can provide only value as integer
• padding (tinyint[2], int[11], smallint[5], bigint[20], boolean[1])
– Padding values for the integer type columns
– Allowed Values (2 - 1024)
© 2019 Magento, Inc. Page | 24
<column/> Integer Attributes
• unsigned (false)
– If column contains negative values need to be true
• identity (false)
– If true column will be auto increment
– The column need to be declared in primary index as well
• nullable (true)
– If column will have NULL values
• comment (no comments are added)
– Comment for the column
• onCreate (empty)
– Helps trigger a task after the column is created
© 2019 Magento, Inc. Page | 25
Declaring text columns
© 2019 Magento, Inc. Page | 26
© 2019 Magento, Inc. Page | 27
<column/> Text Attributes
• name
– Name of the Column
– Required
• xsi:type
– Allowed Values – (varchar, text, mediumtext, longtext)
– Required
• default
– Provide default column value
– Can provided only for varchar
• length
– Length of the field
– varchar allowed max length is 1024
– text mediumtext longtext length can’t be defined
© 2019 Magento, Inc. Page | 28
<column/> Text Attributes
• comment (no comments are added)
– Comment for the column
• nullable (true)
– If column will have NULL values
• onCreate (empty)
– Helps trigger a task after the column is created
© 2019 Magento, Inc. Page | 29
Declaring binary columns
© 2019 Magento, Inc. Page | 30
© 2019 Magento, Inc. Page | 31
<column/> Text Attributes
• xsi:type
– Allowed Values – (varbinary, blob, mediumblob, longblob)
– Required
• default
– Provide default column value
– Can provided only for varbinary
• length
– Length of the field
– varbinary allowed max length is 255
– blob mediumblob longblob length can’t be defined
• comment (no comments are added)
– Comment for the column
© 2019 Magento, Inc. Page | 32
<column/> Text Attributes
• nullable (true)
– If column will have NULL values
• onCreate (empty)
– Helps trigger a task after the column is created
© 2019 Magento, Inc. Page | 33
Declaring decimal
columns
© 2019 Magento, Inc. Page | 34
© 2019 Magento, Inc. Page | 35
<column/> Text Attributes
• xsi:type
– Allowed Values – (decimal, float, double)
– Required
• default
– Provide default column value
• precision
– Total digits of the decimal numbers
• scale
– Total digits after the decimal point
• comment (no comments are added)
– Comment for the column
© 2019 Magento, Inc. Page | 36
<column/> Text Attributes
• nullable (true)
– If column will have NULL values
• unsigned (false)
– If column contains negative values need to be true
• onCreate (empty)
– Helps trigger a task after the column is created
© 2019 Magento, Inc. Page | 37
Declaring a time column
© 2019 Magento, Inc. Page | 38
© 2019 Magento, Inc. Page | 39
<column/> Text Attributes
• name
– Name of the column
– Required
• xsi:type
– Allowed Values – (timestamp, datetime, date)
– Required
• default
– Provide default column value
– Allowed Values – (CURRENT_TIMESTAMP, 0, NULL)
• comment (no comments are added)
– Comment for the column
• on_update (false)
– MySQL on update will be implemented
© 2019 Magento, Inc. Page | 40
<column/> Text Attributes
• nullable (true)
– If column will have NULL values
• onCreate (empty)
– Helps trigger a task after the column is created
© 2019 Magento, Inc. Page | 41
Declaring a primary key
© 2019 Magento, Inc. Page | 42
© 2019 Magento, Inc. Page | 43
Declaring a foreign key
© 2019 Magento, Inc. Page | 44
© 2019 Magento, Inc. Page | 45
Declaring a unique key
© 2019 Magento, Inc. Page | 46
© 2019 Magento, Inc. Page | 47
Declaring an index
© 2019 Magento, Inc. Page | 48
© 2019 Magento, Inc. Page | 49
<index/> Attributes
• indexType
– fulltext
– hash
– btree
© 2019 Magento, Inc. Page | 50
Generating
db_schema_whitelist.json
© 2019 Magento, Inc. Page | 51
© 2019 Magento, Inc. Page | 52
© 2019 Magento, Inc. Page | 53
<module_root>/etc/db_schema_whitelist.json
© 2019 Magento, Inc. Page | 54
© 2019 Magento, Inc. Page | 55
Testing with dry-run
© 2019 Magento, Inc. Page | 56
© 2019 Magento, Inc. Page | 57
© 2019 Magento, Inc. Page | 58
var/log/dry-run-installation.log
© 2019 Magento, Inc. Page | 59
© 2019 Magento, Inc. Page | 60
Applying Database
Schema
© 2019 Magento, Inc. Page | 61
© 2019 Magento, Inc. Page | 62
Modifying the table
column
© 2019 Magento, Inc. Page | 63
© 2019 Magento, Inc. Page | 64
© 2019 Magento, Inc. Page | 65
© 2019 Magento, Inc. Page | 66
Testing with safe-mode
© 2019 Magento, Inc. Page | 67
Destructive Operations
• Deleting a table
• Deleting a column
• Reducing column length
• Changing column precision
• Changing column type
© 2019 Magento, Inc. Page | 68
© 2019 Magento, Inc. Page | 69
var/declarative_dumps_csv/
{column_name_column_type_other_dimensions}.csv
var/declarative_dumps_csv/{table_name}.csv
© 2019 Magento, Inc. Page | 70
Restoring Schema Data
© 2019 Magento, Inc. Page | 71
© 2019 Magento, Inc. Page | 72
Uninstalling a Module
© 2019 Magento, Inc. Page | 73
© 2019 Magento, Inc. Page | 74
Converting Setup Script
to Declarative Schema
© 2019 Magento, Inc. Page | 75
© 2019 Magento, Inc. Page | 76
Limitations
• Custom DDL operations are ignored. It supports only DDL operations that are
present in MagentoFrameworkDBAdapterPdoMysql
• Raw SQL in InstallSchema or UpgradeSchema scripts are ignored.
• DDL statements in the Recurring file won’t be transferred to the new schema
because the file needs to run during each installation or upgrade.
© 2019 Magento, Inc. Page | 77
Questions ?
© 2019 Magento, Inc. Page | 78
Thank You

Más contenido relacionado

La actualidad más candente

Introduction to web sites design
Introduction to  web sites designIntroduction to  web sites design
Introduction to web sites designMarwa Abdelgawad
 
AWS Cloud9과 Workspace만으로 PC없는 개발환경 활용기 (박성용, 허밍랩) :: AWS DevDay 2018
AWS Cloud9과 Workspace만으로 PC없는 개발환경 활용기 (박성용, 허밍랩) :: AWS DevDay 2018AWS Cloud9과 Workspace만으로 PC없는 개발환경 활용기 (박성용, 허밍랩) :: AWS DevDay 2018
AWS Cloud9과 Workspace만으로 PC없는 개발환경 활용기 (박성용, 허밍랩) :: AWS DevDay 2018Amazon Web Services Korea
 
Service Oriented Architecture in Magento 2
Service Oriented Architecture in Magento 2Service Oriented Architecture in Magento 2
Service Oriented Architecture in Magento 2Max Pronko
 
Introduction to ASP.NET Core
Introduction to ASP.NET CoreIntroduction to ASP.NET Core
Introduction to ASP.NET CoreAvanade Nederland
 
Scaling Up to Your First 10 Million Users
Scaling Up to Your First 10 Million UsersScaling Up to Your First 10 Million Users
Scaling Up to Your First 10 Million UsersAmazon Web Services
 
JavaOne 2014 - Supporting Multi-tenancy Applications with Java EE
JavaOne 2014 - Supporting Multi-tenancy Applications with Java EEJavaOne 2014 - Supporting Multi-tenancy Applications with Java EE
JavaOne 2014 - Supporting Multi-tenancy Applications with Java EERodrigo Cândido da Silva
 
Vue.js Getting Started
Vue.js Getting StartedVue.js Getting Started
Vue.js Getting StartedMurat Doğan
 
Magento 2 Design Patterns
Magento 2 Design PatternsMagento 2 Design Patterns
Magento 2 Design PatternsMax Pronko
 
Running gRPC Services for Serving Legacy API on Kubernetes
Running gRPC Services for Serving Legacy API on KubernetesRunning gRPC Services for Serving Legacy API on Kubernetes
Running gRPC Services for Serving Legacy API on KubernetesSungwon Lee
 
Migrating from RDBMS to MongoDB
Migrating from RDBMS to MongoDBMigrating from RDBMS to MongoDB
Migrating from RDBMS to MongoDBMongoDB
 
Docker 간단 개념 / Docker 를 이용한 MSA 기반의 Spring Boot 프로젝트 - DSmentoring 정다운
Docker 간단 개념 / Docker 를 이용한 MSA 기반의 Spring Boot 프로젝트 - DSmentoring 정다운Docker 간단 개념 / Docker 를 이용한 MSA 기반의 Spring Boot 프로젝트 - DSmentoring 정다운
Docker 간단 개념 / Docker 를 이용한 MSA 기반의 Spring Boot 프로젝트 - DSmentoring 정다운다운 정
 

La actualidad más candente (20)

Introduction to web sites design
Introduction to  web sites designIntroduction to  web sites design
Introduction to web sites design
 
AWS Cloud9과 Workspace만으로 PC없는 개발환경 활용기 (박성용, 허밍랩) :: AWS DevDay 2018
AWS Cloud9과 Workspace만으로 PC없는 개발환경 활용기 (박성용, 허밍랩) :: AWS DevDay 2018AWS Cloud9과 Workspace만으로 PC없는 개발환경 활용기 (박성용, 허밍랩) :: AWS DevDay 2018
AWS Cloud9과 Workspace만으로 PC없는 개발환경 활용기 (박성용, 허밍랩) :: AWS DevDay 2018
 
Service Oriented Architecture in Magento 2
Service Oriented Architecture in Magento 2Service Oriented Architecture in Magento 2
Service Oriented Architecture in Magento 2
 
Introduction to ASP.NET Core
Introduction to ASP.NET CoreIntroduction to ASP.NET Core
Introduction to ASP.NET Core
 
Spring annotation
Spring annotationSpring annotation
Spring annotation
 
Scaling Up to Your First 10 Million Users
Scaling Up to Your First 10 Million UsersScaling Up to Your First 10 Million Users
Scaling Up to Your First 10 Million Users
 
JavaOne 2014 - Supporting Multi-tenancy Applications with Java EE
JavaOne 2014 - Supporting Multi-tenancy Applications with Java EEJavaOne 2014 - Supporting Multi-tenancy Applications with Java EE
JavaOne 2014 - Supporting Multi-tenancy Applications with Java EE
 
Vue.js Getting Started
Vue.js Getting StartedVue.js Getting Started
Vue.js Getting Started
 
Web design proposal
Web design proposalWeb design proposal
Web design proposal
 
Magento 2 Design Patterns
Magento 2 Design PatternsMagento 2 Design Patterns
Magento 2 Design Patterns
 
Angular 14.pptx
Angular 14.pptxAngular 14.pptx
Angular 14.pptx
 
Angular js PPT
Angular js PPTAngular js PPT
Angular js PPT
 
Magento 2
Magento 2Magento 2
Magento 2
 
Running gRPC Services for Serving Legacy API on Kubernetes
Running gRPC Services for Serving Legacy API on KubernetesRunning gRPC Services for Serving Legacy API on Kubernetes
Running gRPC Services for Serving Legacy API on Kubernetes
 
Migrating from RDBMS to MongoDB
Migrating from RDBMS to MongoDBMigrating from RDBMS to MongoDB
Migrating from RDBMS to MongoDB
 
VueJS: The Simple Revolution
VueJS: The Simple RevolutionVueJS: The Simple Revolution
VueJS: The Simple Revolution
 
Azure Cosmos DB
Azure Cosmos DBAzure Cosmos DB
Azure Cosmos DB
 
Docker 간단 개념 / Docker 를 이용한 MSA 기반의 Spring Boot 프로젝트 - DSmentoring 정다운
Docker 간단 개념 / Docker 를 이용한 MSA 기반의 Spring Boot 프로젝트 - DSmentoring 정다운Docker 간단 개념 / Docker 를 이용한 MSA 기반의 Spring Boot 프로젝트 - DSmentoring 정다운
Docker 간단 개념 / Docker 를 이용한 MSA 기반의 Spring Boot 프로젝트 - DSmentoring 정다운
 
WordPress Complete Tutorial
WordPress Complete TutorialWordPress Complete Tutorial
WordPress Complete Tutorial
 
Why Vue.js?
Why Vue.js?Why Vue.js?
Why Vue.js?
 

Similar a Magento 2 Declarative Schema

Eugene Shaksuvarov - Tuning Magento 2 for Maximum Performance
Eugene Shaksuvarov - Tuning Magento 2 for Maximum PerformanceEugene Shaksuvarov - Tuning Magento 2 for Maximum Performance
Eugene Shaksuvarov - Tuning Magento 2 for Maximum PerformanceMeet Magento Italy
 
Using Magento 2.3 MySQL Queues
Using Magento 2.3 MySQL QueuesUsing Magento 2.3 MySQL Queues
Using Magento 2.3 MySQL QueuesRenu Mishra
 
Backward Compatibility Developer's Guide in Magento 2. #MM17CZ
Backward Compatibility Developer's Guide in Magento 2. #MM17CZBackward Compatibility Developer's Guide in Magento 2. #MM17CZ
Backward Compatibility Developer's Guide in Magento 2. #MM17CZIgor Miniailo
 
Backward Compatibility Developer's Guide in Magento 2
Backward Compatibility Developer's Guide in Magento 2Backward Compatibility Developer's Guide in Magento 2
Backward Compatibility Developer's Guide in Magento 2Igor Miniailo
 
Imagine recap-devhub
Imagine recap-devhubImagine recap-devhub
Imagine recap-devhubMagento Dev
 
Le novità di sql server 2019
Le novità di sql server 2019Le novità di sql server 2019
Le novità di sql server 2019Gianluca Hotz
 
Oracle 12.2 - My Favorite Top 5 New or Improved Features
Oracle 12.2 - My Favorite Top 5 New or Improved FeaturesOracle 12.2 - My Favorite Top 5 New or Improved Features
Oracle 12.2 - My Favorite Top 5 New or Improved FeaturesSolarWinds
 
Talentica - JS Meetup - Angular Schematics
Talentica - JS Meetup - Angular SchematicsTalentica - JS Meetup - Angular Schematics
Talentica - JS Meetup - Angular SchematicsKrishnan Mudaliar
 
Developing with .NET Core on AWS: What's New (DEV318-R1) - AWS re:Invent 2018
Developing with .NET Core on AWS: What's New (DEV318-R1) - AWS re:Invent 2018Developing with .NET Core on AWS: What's New (DEV318-R1) - AWS re:Invent 2018
Developing with .NET Core on AWS: What's New (DEV318-R1) - AWS re:Invent 2018Amazon Web Services
 
Presto Strata London 2019: Cost-Based Optimizer for interactive SQL on anything
Presto Strata London 2019: Cost-Based Optimizer for interactive SQL on anythingPresto Strata London 2019: Cost-Based Optimizer for interactive SQL on anything
Presto Strata London 2019: Cost-Based Optimizer for interactive SQL on anythingPiotr Findeisen
 
Novedades de MongoDB 3.6
Novedades de MongoDB 3.6Novedades de MongoDB 3.6
Novedades de MongoDB 3.6MongoDB
 
How to upgrade like a boss to MySQL 8.0 - PLE19
How to upgrade like a boss to MySQL 8.0 -  PLE19How to upgrade like a boss to MySQL 8.0 -  PLE19
How to upgrade like a boss to MySQL 8.0 - PLE19Alkin Tezuysal
 
Starburst Presto - CBO talk - Strata London 2019
Starburst Presto  - CBO talk - Strata London 2019Starburst Presto  - CBO talk - Strata London 2019
Starburst Presto - CBO talk - Strata London 2019Justin Borgman
 
[AWS Innovate 온라인 컨퍼런스] Kubernetes와 SageMaker를 활용하여 Machine Learning 워크로드 관리하...
[AWS Innovate 온라인 컨퍼런스] Kubernetes와 SageMaker를 활용하여 Machine Learning 워크로드 관리하...[AWS Innovate 온라인 컨퍼런스] Kubernetes와 SageMaker를 활용하여 Machine Learning 워크로드 관리하...
[AWS Innovate 온라인 컨퍼런스] Kubernetes와 SageMaker를 활용하여 Machine Learning 워크로드 관리하...Amazon Web Services Korea
 
Backwards Compatibility Developers Guide. #MM17NL
Backwards Compatibility Developers Guide. #MM17NLBackwards Compatibility Developers Guide. #MM17NL
Backwards Compatibility Developers Guide. #MM17NLIgor Miniailo
 
Memory Management Made Simple: Kevin Mcghee, Madelyn Olson
Memory Management Made Simple: Kevin Mcghee, Madelyn OlsonMemory Management Made Simple: Kevin Mcghee, Madelyn Olson
Memory Management Made Simple: Kevin Mcghee, Madelyn OlsonRedis Labs
 
MuleSoft Meetup 3 Charlotte Presentation Slides
MuleSoft Meetup 3 Charlotte Presentation SlidesMuleSoft Meetup 3 Charlotte Presentation Slides
MuleSoft Meetup 3 Charlotte Presentation SlidesSubhash Patel
 
利用Fargate無伺服器的容器環境建置高可用的系統
利用Fargate無伺服器的容器環境建置高可用的系統利用Fargate無伺服器的容器環境建置高可用的系統
利用Fargate無伺服器的容器環境建置高可用的系統Amazon Web Services
 

Similar a Magento 2 Declarative Schema (20)

Eugene Shaksuvarov - Tuning Magento 2 for Maximum Performance
Eugene Shaksuvarov - Tuning Magento 2 for Maximum PerformanceEugene Shaksuvarov - Tuning Magento 2 for Maximum Performance
Eugene Shaksuvarov - Tuning Magento 2 for Maximum Performance
 
Using Magento 2.3 MySQL Queues
Using Magento 2.3 MySQL QueuesUsing Magento 2.3 MySQL Queues
Using Magento 2.3 MySQL Queues
 
Backward Compatibility Developer's Guide in Magento 2. #MM17CZ
Backward Compatibility Developer's Guide in Magento 2. #MM17CZBackward Compatibility Developer's Guide in Magento 2. #MM17CZ
Backward Compatibility Developer's Guide in Magento 2. #MM17CZ
 
Backward Compatibility Developer's Guide in Magento 2
Backward Compatibility Developer's Guide in Magento 2Backward Compatibility Developer's Guide in Magento 2
Backward Compatibility Developer's Guide in Magento 2
 
Imagine recap-devhub
Imagine recap-devhubImagine recap-devhub
Imagine recap-devhub
 
Data harmony update 2021
Data harmony update 2021 Data harmony update 2021
Data harmony update 2021
 
Le novità di sql server 2019
Le novità di sql server 2019Le novità di sql server 2019
Le novità di sql server 2019
 
Oracle 12.2 - My Favorite Top 5 New or Improved Features
Oracle 12.2 - My Favorite Top 5 New or Improved FeaturesOracle 12.2 - My Favorite Top 5 New or Improved Features
Oracle 12.2 - My Favorite Top 5 New or Improved Features
 
Talentica - JS Meetup - Angular Schematics
Talentica - JS Meetup - Angular SchematicsTalentica - JS Meetup - Angular Schematics
Talentica - JS Meetup - Angular Schematics
 
Developing with .NET Core on AWS: What's New (DEV318-R1) - AWS re:Invent 2018
Developing with .NET Core on AWS: What's New (DEV318-R1) - AWS re:Invent 2018Developing with .NET Core on AWS: What's New (DEV318-R1) - AWS re:Invent 2018
Developing with .NET Core on AWS: What's New (DEV318-R1) - AWS re:Invent 2018
 
Hidden gems in cf2016
Hidden gems in cf2016Hidden gems in cf2016
Hidden gems in cf2016
 
Presto Strata London 2019: Cost-Based Optimizer for interactive SQL on anything
Presto Strata London 2019: Cost-Based Optimizer for interactive SQL on anythingPresto Strata London 2019: Cost-Based Optimizer for interactive SQL on anything
Presto Strata London 2019: Cost-Based Optimizer for interactive SQL on anything
 
Novedades de MongoDB 3.6
Novedades de MongoDB 3.6Novedades de MongoDB 3.6
Novedades de MongoDB 3.6
 
How to upgrade like a boss to MySQL 8.0 - PLE19
How to upgrade like a boss to MySQL 8.0 -  PLE19How to upgrade like a boss to MySQL 8.0 -  PLE19
How to upgrade like a boss to MySQL 8.0 - PLE19
 
Starburst Presto - CBO talk - Strata London 2019
Starburst Presto  - CBO talk - Strata London 2019Starburst Presto  - CBO talk - Strata London 2019
Starburst Presto - CBO talk - Strata London 2019
 
[AWS Innovate 온라인 컨퍼런스] Kubernetes와 SageMaker를 활용하여 Machine Learning 워크로드 관리하...
[AWS Innovate 온라인 컨퍼런스] Kubernetes와 SageMaker를 활용하여 Machine Learning 워크로드 관리하...[AWS Innovate 온라인 컨퍼런스] Kubernetes와 SageMaker를 활용하여 Machine Learning 워크로드 관리하...
[AWS Innovate 온라인 컨퍼런스] Kubernetes와 SageMaker를 활용하여 Machine Learning 워크로드 관리하...
 
Backwards Compatibility Developers Guide. #MM17NL
Backwards Compatibility Developers Guide. #MM17NLBackwards Compatibility Developers Guide. #MM17NL
Backwards Compatibility Developers Guide. #MM17NL
 
Memory Management Made Simple: Kevin Mcghee, Madelyn Olson
Memory Management Made Simple: Kevin Mcghee, Madelyn OlsonMemory Management Made Simple: Kevin Mcghee, Madelyn Olson
Memory Management Made Simple: Kevin Mcghee, Madelyn Olson
 
MuleSoft Meetup 3 Charlotte Presentation Slides
MuleSoft Meetup 3 Charlotte Presentation SlidesMuleSoft Meetup 3 Charlotte Presentation Slides
MuleSoft Meetup 3 Charlotte Presentation Slides
 
利用Fargate無伺服器的容器環境建置高可用的系統
利用Fargate無伺服器的容器環境建置高可用的系統利用Fargate無伺服器的容器環境建置高可用的系統
利用Fargate無伺服器的容器環境建置高可用的系統
 

Último

Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
How To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTROHow To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTROmotivationalword821
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...Akihiro Suda
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 

Último (20)

Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
How To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTROHow To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTRO
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 

Magento 2 Declarative Schema

  • 1. © 2019 Magento, Inc. Page | 1 Magento 2.3 Declarative Schema
  • 2. © 2019 Magento, Inc. . Page | 2 Lead Developer at BORN Group Atish Goswami
  • 3. © 2019 Magento, Inc. Page | 3 Agenda
  • 4. © 2019 Magento, Inc. Page | 4 Agenda • What is Declarative Schema ? • Declaring table schemes • Updating existing table schemes • New CLI commands and arguments • Schema Rollback
  • 5. © 2019 Magento, Inc. Page | 5 Not In Scope
  • 6. © 2019 Magento, Inc. Page | 6 Not in Scope • Applying Data Patches • Patch Rollbacks • Schema Patches (Trigger/Stored Procedures)
  • 7. © 2019 Magento, Inc. Page | 7 What is Declarative Schema ?
  • 8. © 2019 Magento, Inc. Page | 8 Declarative Schema • Newer way of handling Setup Script Operations • Setup Scripts are still supported in 2.3.x versions (EOL unknown) • Might be Backported to 2.2.x newer versions • Declarative Schema and Setup Scripts don’t work together • If developing backwards compatible modules use Setup Script
  • 9. © 2019 Magento, Inc. Page | 9 Why Declarative Schema ?
  • 10. © 2019 Magento, Inc. Page | 10 Issues with Setup Scripts • Setup Scripts get complicated to manage overtime • Module sequencing needs to be handled properly • Confusing to manage Install vs Upgrade scripts • Version number mishap happens • No Rollbacks
  • 11. © 2019 Magento, Inc. Page | 11 Will Declarative Schema help ?
  • 12. © 2019 Magento, Inc. Page | 12 Declarative Schema Offers • Avoidance of missed/repeated SQL operations • Installation testing using dry-run mode • Performance optimization • Support for rollbacks *
  • 13. © 2019 Magento, Inc. Page | 13 Getting Started
  • 14. © 2019 Magento, Inc. Page | 14 <module_root>/registration.php
  • 15. © 2019 Magento, Inc. Page | 15 <module_root>/etc/module.xml Note : Declarative Schema does not require version number
  • 16. © 2019 Magento, Inc. Page | 16 <module_root>/etc/db_schema.xml New xml file introduced by Declarative Schema
  • 17. © 2019 Magento, Inc. Page | 17 Declaring a table
  • 18. © 2019 Magento, Inc. Page | 18
  • 19. © 2019 Magento, Inc. Page | 19 <table/> Attributes • name – Name of the table – Required • resource (default) – Database connection to use for the operation – Allowed values – default, sales, checkout • engine (innodb) – MySQL Table engine – Allowed values – innodb, memory
  • 20. © 2019 Magento, Inc. Page | 20 <table/> Attributes (Contd) • comment (not comments added) – Comment Relating the table • charset (utf8) – Charset for the table • collation (utf8_general_ci) – Collation to match the charset • onCreate (empty) – Helps trigger a task after the table is created
  • 21. © 2019 Magento, Inc. Page | 21 Declaring integer columns
  • 22. © 2019 Magento, Inc. Page | 22 <module_root>/etc/db_schema.xml
  • 23. © 2019 Magento, Inc. Page | 23 <column/> Integer Attributes • name – Name of the column – Required • xsi:type – Allowed Values – (tinyint, int, smallint, bigint, boolean) – Required • default (NULL) – Provide default column value – Can provide only value as integer • padding (tinyint[2], int[11], smallint[5], bigint[20], boolean[1]) – Padding values for the integer type columns – Allowed Values (2 - 1024)
  • 24. © 2019 Magento, Inc. Page | 24 <column/> Integer Attributes • unsigned (false) – If column contains negative values need to be true • identity (false) – If true column will be auto increment – The column need to be declared in primary index as well • nullable (true) – If column will have NULL values • comment (no comments are added) – Comment for the column • onCreate (empty) – Helps trigger a task after the column is created
  • 25. © 2019 Magento, Inc. Page | 25 Declaring text columns
  • 26. © 2019 Magento, Inc. Page | 26
  • 27. © 2019 Magento, Inc. Page | 27 <column/> Text Attributes • name – Name of the Column – Required • xsi:type – Allowed Values – (varchar, text, mediumtext, longtext) – Required • default – Provide default column value – Can provided only for varchar • length – Length of the field – varchar allowed max length is 1024 – text mediumtext longtext length can’t be defined
  • 28. © 2019 Magento, Inc. Page | 28 <column/> Text Attributes • comment (no comments are added) – Comment for the column • nullable (true) – If column will have NULL values • onCreate (empty) – Helps trigger a task after the column is created
  • 29. © 2019 Magento, Inc. Page | 29 Declaring binary columns
  • 30. © 2019 Magento, Inc. Page | 30
  • 31. © 2019 Magento, Inc. Page | 31 <column/> Text Attributes • xsi:type – Allowed Values – (varbinary, blob, mediumblob, longblob) – Required • default – Provide default column value – Can provided only for varbinary • length – Length of the field – varbinary allowed max length is 255 – blob mediumblob longblob length can’t be defined • comment (no comments are added) – Comment for the column
  • 32. © 2019 Magento, Inc. Page | 32 <column/> Text Attributes • nullable (true) – If column will have NULL values • onCreate (empty) – Helps trigger a task after the column is created
  • 33. © 2019 Magento, Inc. Page | 33 Declaring decimal columns
  • 34. © 2019 Magento, Inc. Page | 34
  • 35. © 2019 Magento, Inc. Page | 35 <column/> Text Attributes • xsi:type – Allowed Values – (decimal, float, double) – Required • default – Provide default column value • precision – Total digits of the decimal numbers • scale – Total digits after the decimal point • comment (no comments are added) – Comment for the column
  • 36. © 2019 Magento, Inc. Page | 36 <column/> Text Attributes • nullable (true) – If column will have NULL values • unsigned (false) – If column contains negative values need to be true • onCreate (empty) – Helps trigger a task after the column is created
  • 37. © 2019 Magento, Inc. Page | 37 Declaring a time column
  • 38. © 2019 Magento, Inc. Page | 38
  • 39. © 2019 Magento, Inc. Page | 39 <column/> Text Attributes • name – Name of the column – Required • xsi:type – Allowed Values – (timestamp, datetime, date) – Required • default – Provide default column value – Allowed Values – (CURRENT_TIMESTAMP, 0, NULL) • comment (no comments are added) – Comment for the column • on_update (false) – MySQL on update will be implemented
  • 40. © 2019 Magento, Inc. Page | 40 <column/> Text Attributes • nullable (true) – If column will have NULL values • onCreate (empty) – Helps trigger a task after the column is created
  • 41. © 2019 Magento, Inc. Page | 41 Declaring a primary key
  • 42. © 2019 Magento, Inc. Page | 42
  • 43. © 2019 Magento, Inc. Page | 43 Declaring a foreign key
  • 44. © 2019 Magento, Inc. Page | 44
  • 45. © 2019 Magento, Inc. Page | 45 Declaring a unique key
  • 46. © 2019 Magento, Inc. Page | 46
  • 47. © 2019 Magento, Inc. Page | 47 Declaring an index
  • 48. © 2019 Magento, Inc. Page | 48
  • 49. © 2019 Magento, Inc. Page | 49 <index/> Attributes • indexType – fulltext – hash – btree
  • 50. © 2019 Magento, Inc. Page | 50 Generating db_schema_whitelist.json
  • 51. © 2019 Magento, Inc. Page | 51
  • 52. © 2019 Magento, Inc. Page | 52
  • 53. © 2019 Magento, Inc. Page | 53 <module_root>/etc/db_schema_whitelist.json
  • 54. © 2019 Magento, Inc. Page | 54
  • 55. © 2019 Magento, Inc. Page | 55 Testing with dry-run
  • 56. © 2019 Magento, Inc. Page | 56
  • 57. © 2019 Magento, Inc. Page | 57
  • 58. © 2019 Magento, Inc. Page | 58 var/log/dry-run-installation.log
  • 59. © 2019 Magento, Inc. Page | 59
  • 60. © 2019 Magento, Inc. Page | 60 Applying Database Schema
  • 61. © 2019 Magento, Inc. Page | 61
  • 62. © 2019 Magento, Inc. Page | 62 Modifying the table column
  • 63. © 2019 Magento, Inc. Page | 63
  • 64. © 2019 Magento, Inc. Page | 64
  • 65. © 2019 Magento, Inc. Page | 65
  • 66. © 2019 Magento, Inc. Page | 66 Testing with safe-mode
  • 67. © 2019 Magento, Inc. Page | 67 Destructive Operations • Deleting a table • Deleting a column • Reducing column length • Changing column precision • Changing column type
  • 68. © 2019 Magento, Inc. Page | 68
  • 69. © 2019 Magento, Inc. Page | 69 var/declarative_dumps_csv/ {column_name_column_type_other_dimensions}.csv var/declarative_dumps_csv/{table_name}.csv
  • 70. © 2019 Magento, Inc. Page | 70 Restoring Schema Data
  • 71. © 2019 Magento, Inc. Page | 71
  • 72. © 2019 Magento, Inc. Page | 72 Uninstalling a Module
  • 73. © 2019 Magento, Inc. Page | 73
  • 74. © 2019 Magento, Inc. Page | 74 Converting Setup Script to Declarative Schema
  • 75. © 2019 Magento, Inc. Page | 75
  • 76. © 2019 Magento, Inc. Page | 76 Limitations • Custom DDL operations are ignored. It supports only DDL operations that are present in MagentoFrameworkDBAdapterPdoMysql • Raw SQL in InstallSchema or UpgradeSchema scripts are ignored. • DDL statements in the Recurring file won’t be transferred to the new schema because the file needs to run during each installation or upgrade.
  • 77. © 2019 Magento, Inc. Page | 77 Questions ?
  • 78. © 2019 Magento, Inc. Page | 78 Thank You