Intro to Database Migrations in Spring Boot 3 with Flyway

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 ส.ค. 2024
  • Database migration is an essential process in software development. It ensures that changes made to the database schema are correctly applied to all environments, including development, staging, and production. Spring Boot, a popular Java framework for web development, provides a useful tool for implementing database migrations called Flyway.
    Flyway is an open-source database migration tool that helps developers manage database schema changes effectively. It tracks changes and applies them to the database in a systematic way, preserving data integrity and consistency across all environments.
    In this video, we will look at how to integrate Flyway into a Spring Boot 3 application and use it to manage database migrations effectively. We will cover the basic concepts of Flyway, such as its configuration, the creation and execution of migration scripts, and database versioning.
    By the end of this article, you will have a solid understanding of how to use Flyway to manage database changes, ensuring that your application’s data remains accurate and consistent across all environments.
    👉👉Grab the source (on github): t.ly/IHnMv
    🔗Grab My Other Products Available:
    - Build Your First Web Service API Using Java Spring Boot wazoowebbytes.gumroad.com/l/x...
    🔗Resources & Links mentioned in this video:
    - Start.spring.io: start.spring.io
    - Flyway: flywaydb.org/
    - Some SQL basics: www.w3schools.com/sql/default...
    👋🏻Connect with me:
    Twitter: / eyuzwa
    ===---=== Concepts ===---===
    - Spring Boot
    - Database Migrations
    - Flyway
    - Rollbacks
    ===---=== Chapters ===---===
    0:00:00 - Introduction
    0:00:12 - What are Database Migrations?
    0:07:36 - Start.spring.io Project
    0:08:49 - Opening Project in IDE
    0:09:11 - Link the Spring Boot Blog Application
    0:09:37 - Setting our Application Properties
    0:11:29 - Setting up the Resources/db/migration folder
    0:12:11 - First cut of our Post Model
    0:12:41 - Creating the First Migration
    0:14:13 - Running the First Migration
    0:15:05 - Checking out the Database
    0:16:06 - Changing the Post Object Model
    0:16:57 - Adding another Migration
    0:18:36 - Adding a Sequence for our Post @Id
    0:19:34 - Add Post Sequence Migration
    0:20:52 - Check Updated Database Schema
    0:21:33 - Add Authority Model
    0:22:29 - Create Authority Table Migration
    0:23:10 - Add Account Model
    0:24:27 - Create Account Table Migration
    0:26:42 - Add @OneToMany relationship from Account to Post
    0:27:55 - Add Migration for account_id in Post Table
    0:28:37 - @ManyToMany relationship from Account to Authority
    0:29:31 - Create Account_Authority Table Migration
    0:30:39 - A brief discussion about Rollbacks
    0:31:40 - Creating test Migrations to demonstrate Rollback
    0:33:57 - Wrapping Up
    #java
    #springboot
    #springboottutorial
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 21

  • @abhishekomprakash4074
    @abhishekomprakash4074 4 หลายเดือนก่อน

    Enjoyed learning from your video. Thanks!

    • @wazoowebbytes
      @wazoowebbytes  4 หลายเดือนก่อน

      I'm so glad it helped you out! Thanks for mentioning it.

  • @barchynaiiakubova1778
    @barchynaiiakubova1778 8 หลายเดือนก่อน +1

    Was very useful. Thank you a lot.

    • @wazoowebbytes
      @wazoowebbytes  8 หลายเดือนก่อน

      Thanks so much - glad it helped!

  • @user-mv2dq1xr4v
    @user-mv2dq1xr4v ปีที่แล้ว

    Thank you great explanation!🤟

  • @Mohamed-uf5jh
    @Mohamed-uf5jh ปีที่แล้ว +1

    Good explain, thanks

    • @wazoowebbytes
      @wazoowebbytes  ปีที่แล้ว

      thanks a lot! I appreciate the note

  • @wazoowebbytes
    @wazoowebbytes  ปีที่แล้ว +1

    Hope this helps you with understanding what database migrations are and how they might help you! What problems have you come across with migrations in your own journey?

  • @darcyallen
    @darcyallen ปีที่แล้ว

    Spiky hair doo! Looks like you had your coffee that day :D
    🤣

    • @wazoowebbytes
      @wazoowebbytes  ปีที่แล้ว

      Yeah it's getting out of control

  • @Pest87
    @Pest87 8 หลายเดือนก่อน +1

    Great and very useful. I think just there was one mistake - in the accounts_authorities table(the many to many) the account id shouldnt be a primary key, because we can have more than 1 entry with the same account id?

    • @wazoowebbytes
      @wazoowebbytes  8 หลายเดือนก่อน

      hmm you could be right. I've worked on projects that chose to do it this way, but also on others where there was no primary key on the join (many to many) table. Thanks for the input - I'll think about it!

  • @a7mdFathii
    @a7mdFathii 7 หลายเดือนก่อน

    first, thanks for this tutorial. it's very helpful but how the code run when your model contain firstName and migration script contain first_name ? this applied to all properties that contain underscore
    also, I try to add create table and create sequence in same script it get error.

    • @wazoowebbytes
      @wazoowebbytes  7 หลายเดือนก่อน

      hi and thanks for asking! Yes, maybe I've done a poor job explaining that. In the JPA layer, if your model property name is "firstName", then when it wants to do the mapping with your database, it's expecting an underscore before the capitalized letter - aka. "first_name". I'm sorry I didn't try to explain that clearly!! So if your model property name is "lastName", then the database column would (by default) be "last_name" - this can be overridden if you choose. Hope that helps!

    • @a7mdFathii
      @a7mdFathii 7 หลายเดือนก่อน

      @@wazoowebbytes thanks for responding to me fast. I was thinking that there is another way to handle this underscore. so, thanks.

  • @kmac1203
    @kmac1203 ปีที่แล้ว +1

    no properties needed for flyway?

    • @wazoowebbytes
      @wazoowebbytes  ปีที่แล้ว

      Hey, I just double checked what I uploaded to github to make sure, and no - I was able to get the basics going without configuring any properties

  • @MrRANDUM145
    @MrRANDUM145 ปีที่แล้ว

    Kind've random but you look just like Alexei from black widow!

    • @wazoowebbytes
      @wazoowebbytes  ปีที่แล้ว

      heh thanks! But that means I gotta shave more

    • @MrRANDUM145
      @MrRANDUM145 ปีที่แล้ว

      @@wazoowebbytes no you should grow out a great big beard so you can go as him for Halloween hahaha