SlideShare a Scribd company logo
Len Chang
08.18 2019
1
▪ Me
▪ The introduction of knex.js
▪ What’s the problem that schema change ?
▪ Create seed data and migration files
▪ How to solve the problem ?
▪ Integrate it with Bitbucket pipeline
▪ Q & A
2
▪ Len Chang
▪ Engineer
▪ Like..
▪ Baseball / Beer / Finance
▪ Coding
▪ JavaScript / Typescript
▪ DB
▪ PostgreSQL / Elasticsearch
▪ Volunteer
▪ Nantou Code Geek
▪ You can find me..
▪ LinkedIn
▪ Facebook
▪ PPT Online
3
Library Docs (Link)
4
▪ Knex.js is a "batteries included" SQL query builder
for Postgres, MSSQL, MySQL, MariaDB, SQLite3, Oracle, and Amazon
Redshift designed to be flexible, portable, and fun to use.
▪ Basically it’s the major choice when you use nodejs and RDBMS to do the backend
server.
▪ Features
▪ Query Builder
▪ Pooling
▪ Transactions
▪ Migrations
▪ Seed files
5
▪ Query Builder
▪ The heart of the library, the knex query builder is the interface used for building and
executing standard SQL queries, such as select, insert, update, delete.
▪ Example
knex({ a: 'table', b: 'table' })
.select({
aTitle: 'a.title',
bTitle: 'b.title'
})
.whereRaw('?? = ??', ['a.column_1', 'b.column_2’])
// select "a"."title" as "aTitle", "b"."title" as "bTitle" from "table" as "a", "table" as "b" where "a"."column_1" = "b"."column_2"
6
Application
▪ Pooling
▪ The client created by the configuration initializes a connection pool, using the tarn.js
library. This connection pool has a default setting of a min: 2, max: 10
7
Pooling
Action
Action
Action
PG
Application
Action
Action
Action
PG
▪ Transactions
▪ All queries within a transaction are executed on the same database connection, and run
the entire set of queries as a single unit of work. Any failure will mean the database will
rollback any queries executed on that connection to the pre-transaction state.
▪ Methods
1. As a transaction object
2. As a query builder
8
as a transaction object
▪ Transactions
▪ Methods
1. As a transaction object
2. As a query builder
9
as a transaction object
▪ Migrations
▪ Migrations allow for you to define sets of schema changes so upgrading a database is a
breeze.
10
▪ Seed files
▪ Seed files allow you to populate your database with test or seed data independent of your
migration files.
11
Run seed
12
Testing
1. How to avoid crashing when you
update schema ?
▪ Testing
2. How to avoid operation error ?
▪ Deploy system automatically
13
DB
(version + 1)
Script:
Updating schema
Success (Commit) Failed (Rollback)
DB
(version + 1)
DB
(version)
Dev DB
Script:
Updating schema
QA DB
PROD DB
Dev DB
Dev DB
QA DB
Script:
Updating schemaScript:
Updating schema
3. Doesn’t need to use another tool or code language to do it.
▪ Just JavaScript
14
▪ Summary
▪ How to avoid crashing when you updated schema ?
▪ Testing
▪ How to avoid operation error ?
▪ Deploying system automatically
▪ Doesn’t need to use another tool or code language to do it
▪ Just JavaScript
15
16
▪ Migration
1. knex init => knexfile.ts
17
▪ Migration
2. knex migrate:make migration
▪ Up / Down Functions
18
▪ Migration
3. knex migrate:latest
19
Check migration record
Run
unrecorded
files
▪ Migration Process
20
knexfile.ts
20190814170951_migration.ts
Success (Commit)Failed (Rollback)
Run Migration
▪ Seed data
1. knex init => knexfile.ts
21
▪ Seed data
2. Create seed data
22
▪ Seed data
3. Create seed handling script
and Running
23
▪ Seed Process
24
Seed data of tables
Seed handling Scripts
knex seed:run
DB
Testing, deploying system automatically and just javascript !
25
▪ Testing
▪ Embedded seed testing in migration
Process
26
Transaction
Transaction
▪ Testing
▪ Dividing Environment
▪ All migration script is knex migrate:latest, but
it run different script by different env.
27
▪ deploying system automatically
28
▪ Just javascript
▪ …well…. Just you said that….only javascript.
29
30
31
▪ Advantage
▪ Reduce operation error !
▪ Deploy schema simpler and safer.
▪ Do it by JS developer.
32
LinkedIn
Facebook
PPT Online
33
Ad

More Related Content

What's hot (20)

Is It Fast? : Measuring MongoDB Performance
Is It Fast? : Measuring MongoDB PerformanceIs It Fast? : Measuring MongoDB Performance
Is It Fast? : Measuring MongoDB Performance
Tim Callaghan
 
dba_lounge_Iasi: Everybody likes redis
dba_lounge_Iasi: Everybody likes redisdba_lounge_Iasi: Everybody likes redis
dba_lounge_Iasi: Everybody likes redis
Liviu Costea
 
When is MyRocks good?
When is MyRocks good? When is MyRocks good?
When is MyRocks good?
Alkin Tezuysal
 
InnoDB Scalability improvements in MySQL 8.0
InnoDB Scalability improvements in MySQL 8.0InnoDB Scalability improvements in MySQL 8.0
InnoDB Scalability improvements in MySQL 8.0
Mydbops
 
Couch Db
Couch DbCouch Db
Couch Db
Ross Lawley
 
MySQL on AWS RDS
MySQL on AWS RDSMySQL on AWS RDS
MySQL on AWS RDS
Mydbops
 
Webpack
WebpackWebpack
Webpack
Mallikarjuna G D
 
WiredTiger Overview
WiredTiger OverviewWiredTiger Overview
WiredTiger Overview
WiredTiger
 
MySQL topology healing at OLA.
MySQL topology healing at OLA.MySQL topology healing at OLA.
MySQL topology healing at OLA.
Mydbops
 
What is new in Galera 4 ?
What is new in Galera 4 ?What is new in Galera 4 ?
What is new in Galera 4 ?
Mydbops
 
Redis
RedisRedis
Redis
Ramon Wartala
 
SQL, NoSQL, NewSQL? What's a developer to do?
SQL, NoSQL, NewSQL? What's a developer to do?SQL, NoSQL, NewSQL? What's a developer to do?
SQL, NoSQL, NewSQL? What's a developer to do?
Chris Richardson
 
NewSQL overview, Feb 2015
NewSQL overview, Feb 2015NewSQL overview, Feb 2015
NewSQL overview, Feb 2015
Ivan Glushkov
 
Evolution of MySQL Parallel Replication
Evolution of MySQL Parallel Replication Evolution of MySQL Parallel Replication
Evolution of MySQL Parallel Replication
Mydbops
 
Redis Overview
Redis OverviewRedis Overview
Redis Overview
Hoang Long
 
MySQL Performance Schema in Action
MySQL Performance Schema in Action MySQL Performance Schema in Action
MySQL Performance Schema in Action
Mydbops
 
Building Hybrid data cluster using PostgreSQL and MongoDB
Building Hybrid data cluster using PostgreSQL and MongoDBBuilding Hybrid data cluster using PostgreSQL and MongoDB
Building Hybrid data cluster using PostgreSQL and MongoDB
Ashnikbiz
 
Redis IU
Redis IURedis IU
Redis IU
Isaiah Edem
 
MongoDB basics & Introduction
MongoDB basics & IntroductionMongoDB basics & Introduction
MongoDB basics & Introduction
Jerwin Roy
 
Making MySQL Agile-ish
Making MySQL Agile-ishMaking MySQL Agile-ish
Making MySQL Agile-ish
Dave Stokes
 
Is It Fast? : Measuring MongoDB Performance
Is It Fast? : Measuring MongoDB PerformanceIs It Fast? : Measuring MongoDB Performance
Is It Fast? : Measuring MongoDB Performance
Tim Callaghan
 
dba_lounge_Iasi: Everybody likes redis
dba_lounge_Iasi: Everybody likes redisdba_lounge_Iasi: Everybody likes redis
dba_lounge_Iasi: Everybody likes redis
Liviu Costea
 
When is MyRocks good?
When is MyRocks good? When is MyRocks good?
When is MyRocks good?
Alkin Tezuysal
 
InnoDB Scalability improvements in MySQL 8.0
InnoDB Scalability improvements in MySQL 8.0InnoDB Scalability improvements in MySQL 8.0
InnoDB Scalability improvements in MySQL 8.0
Mydbops
 
MySQL on AWS RDS
MySQL on AWS RDSMySQL on AWS RDS
MySQL on AWS RDS
Mydbops
 
WiredTiger Overview
WiredTiger OverviewWiredTiger Overview
WiredTiger Overview
WiredTiger
 
MySQL topology healing at OLA.
MySQL topology healing at OLA.MySQL topology healing at OLA.
MySQL topology healing at OLA.
Mydbops
 
What is new in Galera 4 ?
What is new in Galera 4 ?What is new in Galera 4 ?
What is new in Galera 4 ?
Mydbops
 
SQL, NoSQL, NewSQL? What's a developer to do?
SQL, NoSQL, NewSQL? What's a developer to do?SQL, NoSQL, NewSQL? What's a developer to do?
SQL, NoSQL, NewSQL? What's a developer to do?
Chris Richardson
 
NewSQL overview, Feb 2015
NewSQL overview, Feb 2015NewSQL overview, Feb 2015
NewSQL overview, Feb 2015
Ivan Glushkov
 
Evolution of MySQL Parallel Replication
Evolution of MySQL Parallel Replication Evolution of MySQL Parallel Replication
Evolution of MySQL Parallel Replication
Mydbops
 
Redis Overview
Redis OverviewRedis Overview
Redis Overview
Hoang Long
 
MySQL Performance Schema in Action
MySQL Performance Schema in Action MySQL Performance Schema in Action
MySQL Performance Schema in Action
Mydbops
 
Building Hybrid data cluster using PostgreSQL and MongoDB
Building Hybrid data cluster using PostgreSQL and MongoDBBuilding Hybrid data cluster using PostgreSQL and MongoDB
Building Hybrid data cluster using PostgreSQL and MongoDB
Ashnikbiz
 
MongoDB basics & Introduction
MongoDB basics & IntroductionMongoDB basics & Introduction
MongoDB basics & Introduction
Jerwin Roy
 
Making MySQL Agile-ish
Making MySQL Agile-ishMaking MySQL Agile-ish
Making MySQL Agile-ish
Dave Stokes
 

Similar to COSCUP 2019 - The discussion between Knex.js and PostgreSQL (20)

The Modern Data Team for the Modern Data Stack: dbt and the Role of the Analy...
The Modern Data Team for the Modern Data Stack: dbt and the Role of the Analy...The Modern Data Team for the Modern Data Stack: dbt and the Role of the Analy...
The Modern Data Team for the Modern Data Stack: dbt and the Role of the Analy...
Databricks
 
Handling scale on AWS
Handling scale on AWSHandling scale on AWS
Handling scale on AWS
David Ilievsky
 
001 hbase introduction
001 hbase introduction001 hbase introduction
001 hbase introduction
Scott Miao
 
MyRocks introduction and production deployment
MyRocks introduction and production deploymentMyRocks introduction and production deployment
MyRocks introduction and production deployment
Yoshinori Matsunobu
 
Plantilla oracle
Plantilla oraclePlantilla oracle
Plantilla oracle
Uriel Barrales Garrido
 
ow-123123123123123123123123123123123123123
ow-123123123123123123123123123123123123123ow-123123123123123123123123123123123123123
ow-123123123123123123123123123123123123123
DngHong855117
 
kranonit S06E01 Игорь Цинько: High load
kranonit S06E01 Игорь Цинько: High loadkranonit S06E01 Игорь Цинько: High load
kranonit S06E01 Игорь Цинько: High load
Krivoy Rog IT Community
 
Achieving cyber mission assurance with near real-time impact
Achieving cyber mission assurance with near real-time impactAchieving cyber mission assurance with near real-time impact
Achieving cyber mission assurance with near real-time impact
Elasticsearch
 
Middleware upgrade to Oracle Fusion Middleware(FMW) 12c.Real Case stories.
Middleware upgrade to Oracle Fusion Middleware(FMW) 12c.Real Case stories. Middleware upgrade to Oracle Fusion Middleware(FMW) 12c.Real Case stories.
Middleware upgrade to Oracle Fusion Middleware(FMW) 12c.Real Case stories.
Andrejs Vorobjovs
 
Serverless Compose vs hurtownia danych
Serverless Compose vs hurtownia danychServerless Compose vs hurtownia danych
Serverless Compose vs hurtownia danych
The Software House
 
Encompassing Information Integration
Encompassing Information IntegrationEncompassing Information Integration
Encompassing Information Integration
nguyenfilip
 
Meetup#2: Building responsive Symbology & Suggest WebService
Meetup#2: Building responsive Symbology & Suggest WebServiceMeetup#2: Building responsive Symbology & Suggest WebService
Meetup#2: Building responsive Symbology & Suggest WebService
Minsk MongoDB User Group
 
Lessons from Building Large-Scale, Multi-Cloud, SaaS Software at Databricks
Lessons from Building Large-Scale, Multi-Cloud, SaaS Software at DatabricksLessons from Building Large-Scale, Multi-Cloud, SaaS Software at Databricks
Lessons from Building Large-Scale, Multi-Cloud, SaaS Software at Databricks
Databricks
 
Ow
OwOw
Ow
juanjoaloloco
 
Level 101 for Presto: What is PrestoDB?
Level 101 for Presto: What is PrestoDB?Level 101 for Presto: What is PrestoDB?
Level 101 for Presto: What is PrestoDB?
Ali LeClerc
 
ow.ppt
ow.pptow.ppt
ow.ppt
ssuser96a63c
 
ow.ppt
ow.pptow.ppt
ow.ppt
NalamalpuBhakthavats
 
kjdiakdnfdifjadsjkjklljlldasgjdjdljgfldjgldjgldjgl.ppt
kjdiakdnfdifjadsjkjklljlldasgjdjdljgfldjgldjgldjgl.pptkjdiakdnfdifjadsjkjklljlldasgjdjdljgfldjgldjgldjgl.ppt
kjdiakdnfdifjadsjkjklljlldasgjdjdljgfldjgldjgldjgl.ppt
Brahamam Veera
 
Ow
OwOw
Ow
AlbertoItzincab1
 
Operational foundation for the sql server dba
Operational foundation for the sql server dbaOperational foundation for the sql server dba
Operational foundation for the sql server dba
PeterShore4
 
The Modern Data Team for the Modern Data Stack: dbt and the Role of the Analy...
The Modern Data Team for the Modern Data Stack: dbt and the Role of the Analy...The Modern Data Team for the Modern Data Stack: dbt and the Role of the Analy...
The Modern Data Team for the Modern Data Stack: dbt and the Role of the Analy...
Databricks
 
001 hbase introduction
001 hbase introduction001 hbase introduction
001 hbase introduction
Scott Miao
 
MyRocks introduction and production deployment
MyRocks introduction and production deploymentMyRocks introduction and production deployment
MyRocks introduction and production deployment
Yoshinori Matsunobu
 
ow-123123123123123123123123123123123123123
ow-123123123123123123123123123123123123123ow-123123123123123123123123123123123123123
ow-123123123123123123123123123123123123123
DngHong855117
 
kranonit S06E01 Игорь Цинько: High load
kranonit S06E01 Игорь Цинько: High loadkranonit S06E01 Игорь Цинько: High load
kranonit S06E01 Игорь Цинько: High load
Krivoy Rog IT Community
 
Achieving cyber mission assurance with near real-time impact
Achieving cyber mission assurance with near real-time impactAchieving cyber mission assurance with near real-time impact
Achieving cyber mission assurance with near real-time impact
Elasticsearch
 
Middleware upgrade to Oracle Fusion Middleware(FMW) 12c.Real Case stories.
Middleware upgrade to Oracle Fusion Middleware(FMW) 12c.Real Case stories. Middleware upgrade to Oracle Fusion Middleware(FMW) 12c.Real Case stories.
Middleware upgrade to Oracle Fusion Middleware(FMW) 12c.Real Case stories.
Andrejs Vorobjovs
 
Serverless Compose vs hurtownia danych
Serverless Compose vs hurtownia danychServerless Compose vs hurtownia danych
Serverless Compose vs hurtownia danych
The Software House
 
Encompassing Information Integration
Encompassing Information IntegrationEncompassing Information Integration
Encompassing Information Integration
nguyenfilip
 
Meetup#2: Building responsive Symbology & Suggest WebService
Meetup#2: Building responsive Symbology & Suggest WebServiceMeetup#2: Building responsive Symbology & Suggest WebService
Meetup#2: Building responsive Symbology & Suggest WebService
Minsk MongoDB User Group
 
Lessons from Building Large-Scale, Multi-Cloud, SaaS Software at Databricks
Lessons from Building Large-Scale, Multi-Cloud, SaaS Software at DatabricksLessons from Building Large-Scale, Multi-Cloud, SaaS Software at Databricks
Lessons from Building Large-Scale, Multi-Cloud, SaaS Software at Databricks
Databricks
 
Level 101 for Presto: What is PrestoDB?
Level 101 for Presto: What is PrestoDB?Level 101 for Presto: What is PrestoDB?
Level 101 for Presto: What is PrestoDB?
Ali LeClerc
 
kjdiakdnfdifjadsjkjklljlldasgjdjdljgfldjgldjgldjgl.ppt
kjdiakdnfdifjadsjkjklljlldasgjdjdljgfldjgldjgldjgl.pptkjdiakdnfdifjadsjkjklljlldasgjdjdljgfldjgldjgldjgl.ppt
kjdiakdnfdifjadsjkjklljlldasgjdjdljgfldjgldjgldjgl.ppt
Brahamam Veera
 
Operational foundation for the sql server dba
Operational foundation for the sql server dbaOperational foundation for the sql server dba
Operational foundation for the sql server dba
PeterShore4
 
Ad

More from Len Chang (8)

The issue discussion between dml and ddl deployment
The issue discussion between dml and ddl deploymentThe issue discussion between dml and ddl deployment
The issue discussion between dml and ddl deployment
Len Chang
 
DevOps Taiwan meetup #19
DevOps Taiwan meetup #19DevOps Taiwan meetup #19
DevOps Taiwan meetup #19
Len Chang
 
BI in Xuenn
BI in XuennBI in Xuenn
BI in Xuenn
Len Chang
 
2014 Pixnet Hackathonh - EXIF Mining
2014 Pixnet Hackathonh - EXIF Mining2014 Pixnet Hackathonh - EXIF Mining
2014 Pixnet Hackathonh - EXIF Mining
Len Chang
 
Hadoop con2016 - Implement Real-time Centralized logging System by Elastic Stack
Hadoop con2016 - Implement Real-time Centralized logging System by Elastic StackHadoop con2016 - Implement Real-time Centralized logging System by Elastic Stack
Hadoop con2016 - Implement Real-time Centralized logging System by Elastic Stack
Len Chang
 
Agile scrum in startup
Agile scrum in startup  Agile scrum in startup
Agile scrum in startup
Len Chang
 
Hadoop Con2015 - The Data Scientist’s Toolbox
Hadoop Con2015 - The Data Scientist’s ToolboxHadoop Con2015 - The Data Scientist’s Toolbox
Hadoop Con2015 - The Data Scientist’s Toolbox
Len Chang
 
Spam user detection report
Spam user detection reportSpam user detection report
Spam user detection report
Len Chang
 
The issue discussion between dml and ddl deployment
The issue discussion between dml and ddl deploymentThe issue discussion between dml and ddl deployment
The issue discussion between dml and ddl deployment
Len Chang
 
DevOps Taiwan meetup #19
DevOps Taiwan meetup #19DevOps Taiwan meetup #19
DevOps Taiwan meetup #19
Len Chang
 
2014 Pixnet Hackathonh - EXIF Mining
2014 Pixnet Hackathonh - EXIF Mining2014 Pixnet Hackathonh - EXIF Mining
2014 Pixnet Hackathonh - EXIF Mining
Len Chang
 
Hadoop con2016 - Implement Real-time Centralized logging System by Elastic Stack
Hadoop con2016 - Implement Real-time Centralized logging System by Elastic StackHadoop con2016 - Implement Real-time Centralized logging System by Elastic Stack
Hadoop con2016 - Implement Real-time Centralized logging System by Elastic Stack
Len Chang
 
Agile scrum in startup
Agile scrum in startup  Agile scrum in startup
Agile scrum in startup
Len Chang
 
Hadoop Con2015 - The Data Scientist’s Toolbox
Hadoop Con2015 - The Data Scientist’s ToolboxHadoop Con2015 - The Data Scientist’s Toolbox
Hadoop Con2015 - The Data Scientist’s Toolbox
Len Chang
 
Spam user detection report
Spam user detection reportSpam user detection report
Spam user detection report
Len Chang
 
Ad

Recently uploaded (20)

AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 

COSCUP 2019 - The discussion between Knex.js and PostgreSQL

  • 2. ▪ Me ▪ The introduction of knex.js ▪ What’s the problem that schema change ? ▪ Create seed data and migration files ▪ How to solve the problem ? ▪ Integrate it with Bitbucket pipeline ▪ Q & A 2
  • 3. ▪ Len Chang ▪ Engineer ▪ Like.. ▪ Baseball / Beer / Finance ▪ Coding ▪ JavaScript / Typescript ▪ DB ▪ PostgreSQL / Elasticsearch ▪ Volunteer ▪ Nantou Code Geek ▪ You can find me.. ▪ LinkedIn ▪ Facebook ▪ PPT Online 3
  • 5. ▪ Knex.js is a "batteries included" SQL query builder for Postgres, MSSQL, MySQL, MariaDB, SQLite3, Oracle, and Amazon Redshift designed to be flexible, portable, and fun to use. ▪ Basically it’s the major choice when you use nodejs and RDBMS to do the backend server. ▪ Features ▪ Query Builder ▪ Pooling ▪ Transactions ▪ Migrations ▪ Seed files 5
  • 6. ▪ Query Builder ▪ The heart of the library, the knex query builder is the interface used for building and executing standard SQL queries, such as select, insert, update, delete. ▪ Example knex({ a: 'table', b: 'table' }) .select({ aTitle: 'a.title', bTitle: 'b.title' }) .whereRaw('?? = ??', ['a.column_1', 'b.column_2’]) // select "a"."title" as "aTitle", "b"."title" as "bTitle" from "table" as "a", "table" as "b" where "a"."column_1" = "b"."column_2" 6
  • 7. Application ▪ Pooling ▪ The client created by the configuration initializes a connection pool, using the tarn.js library. This connection pool has a default setting of a min: 2, max: 10 7 Pooling Action Action Action PG Application Action Action Action PG
  • 8. ▪ Transactions ▪ All queries within a transaction are executed on the same database connection, and run the entire set of queries as a single unit of work. Any failure will mean the database will rollback any queries executed on that connection to the pre-transaction state. ▪ Methods 1. As a transaction object 2. As a query builder 8 as a transaction object
  • 9. ▪ Transactions ▪ Methods 1. As a transaction object 2. As a query builder 9 as a transaction object
  • 10. ▪ Migrations ▪ Migrations allow for you to define sets of schema changes so upgrading a database is a breeze. 10
  • 11. ▪ Seed files ▪ Seed files allow you to populate your database with test or seed data independent of your migration files. 11 Run seed
  • 12. 12
  • 13. Testing 1. How to avoid crashing when you update schema ? ▪ Testing 2. How to avoid operation error ? ▪ Deploy system automatically 13 DB (version + 1) Script: Updating schema Success (Commit) Failed (Rollback) DB (version + 1) DB (version) Dev DB Script: Updating schema QA DB PROD DB Dev DB Dev DB QA DB Script: Updating schemaScript: Updating schema
  • 14. 3. Doesn’t need to use another tool or code language to do it. ▪ Just JavaScript 14
  • 15. ▪ Summary ▪ How to avoid crashing when you updated schema ? ▪ Testing ▪ How to avoid operation error ? ▪ Deploying system automatically ▪ Doesn’t need to use another tool or code language to do it ▪ Just JavaScript 15
  • 16. 16
  • 17. ▪ Migration 1. knex init => knexfile.ts 17
  • 18. ▪ Migration 2. knex migrate:make migration ▪ Up / Down Functions 18
  • 19. ▪ Migration 3. knex migrate:latest 19 Check migration record Run unrecorded files
  • 21. ▪ Seed data 1. knex init => knexfile.ts 21
  • 22. ▪ Seed data 2. Create seed data 22
  • 23. ▪ Seed data 3. Create seed handling script and Running 23
  • 24. ▪ Seed Process 24 Seed data of tables Seed handling Scripts knex seed:run DB
  • 25. Testing, deploying system automatically and just javascript ! 25
  • 26. ▪ Testing ▪ Embedded seed testing in migration Process 26 Transaction Transaction
  • 27. ▪ Testing ▪ Dividing Environment ▪ All migration script is knex migrate:latest, but it run different script by different env. 27
  • 28. ▪ deploying system automatically 28
  • 29. ▪ Just javascript ▪ …well…. Just you said that….only javascript. 29
  • 30. 30
  • 31. 31
  • 32. ▪ Advantage ▪ Reduce operation error ! ▪ Deploy schema simpler and safer. ▪ Do it by JS developer. 32