Skip to content

Commit

Permalink
create liquidbase sql for the Reservation and the Reservation entity …
Browse files Browse the repository at this point in the history
…itself
  • Loading branch information
alexkasuka committed Jul 18, 2023
1 parent c4e7367 commit 6ad2ae1
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.zufar.onlinestore.reservation.dto;


import java.time.LocalDateTime;

public record ReservationDto(
int reservationId,
int productId,
int reservedQuantity,
LocalDateTime createdAt,
String reservationStatus
) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.zufar.onlinestore.reservation.entity;

import lombok.Builder;
import org.springframework.data.annotation.Id;

import java.time.LocalDateTime;

@Builder
public record Reservation(
@Id
int reservationId,
int productId,
int reservedQuantity,
LocalDateTime createdAt,
String reservationStatus
) {}

10 changes: 10 additions & 0 deletions src/main/resources/db/changelog/1.1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--changeset Alex Zarubin:1
CREATE TABLE reservation (
reservation_id UUID NOT NULL,
product_id UUID NOT NULL,
reserved_quantity INT NOT NULL CHECK(reserved_amount > 0),
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
reservation_status VARCHAR(32) NOT NULL,
PRIMARY KEY (reservation_id)
);
CREATE UNIQUE INDEX uniq_reservation ON reservation (reservation_id, product_id);
1 change: 1 addition & 0 deletions src/main/resources/db/changelog/db.changelog-master.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">

<include file="classpath:db/changelog/db.changelog-1.0.xml" />
<include file="1.1.sql" relativeToChangelogFile="true" />

</databaseChangeLog>

0 comments on commit 6ad2ae1

Please sign in to comment.