mirror of
https://github.com/OtusTeam/Spring.git
synced 2026-06-20 11:14:34 +00:00
liquibase example some changes
This commit is contained in:
@@ -3,6 +3,9 @@ package ru.otus.spring;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
// url h2 консоли: http://localhost:8080/h2-console
|
||||
// url базы: jdbc:h2:mem:testdb
|
||||
|
||||
@SpringBootApplication
|
||||
public class Main {
|
||||
|
||||
|
||||
+2
-2
@@ -1,11 +1,11 @@
|
||||
--liquibase formatted sql
|
||||
|
||||
--changeset stvort:2020-05-25-002-avatars
|
||||
--changeset stvort:2020-05-25-001-avatars
|
||||
create table avatars (
|
||||
id bigserial,
|
||||
photo_url varchar(255)
|
||||
)
|
||||
|
||||
--changeset stvort:2020-05-25-002-users-avatars-id
|
||||
--changeset stvort:2020-05-25-001-users-avatars-id
|
||||
alter table users
|
||||
add column avatar_id bigint references avatars(id) ON DELETE SET NULL
|
||||
+4
-4
@@ -2,7 +2,7 @@
|
||||
"databaseChangeLog": [
|
||||
{
|
||||
"changeSet": {
|
||||
"id": "2020-05-25--003-emails",
|
||||
"id": "2020-05-25--002-emails",
|
||||
"author": "stvort",
|
||||
"changes": [
|
||||
{
|
||||
@@ -16,8 +16,7 @@
|
||||
"autoIncrement": true,
|
||||
"constraints": {
|
||||
"primaryKey": true,
|
||||
"nullable": false,
|
||||
"deleteCascade": true
|
||||
"nullable": false
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -28,7 +27,8 @@
|
||||
"constraints": {
|
||||
"nullable": false,
|
||||
"foreignKeyName": "fk_emails_users",
|
||||
"references": "users(id)"
|
||||
"references": "users(id)",
|
||||
"deleteCascade": true
|
||||
}
|
||||
}
|
||||
},
|
||||
+2
-2
@@ -5,7 +5,7 @@
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
|
||||
|
||||
<changeSet id="2020-05-25--001-courses" author="stvort">
|
||||
<changeSet id="2020-05-25--003-courses" author="stvort">
|
||||
<createTable tableName="courses">
|
||||
<column name="id" type="bigint" autoIncrement="true">
|
||||
<constraints primaryKey="true" nullable="false"/>
|
||||
@@ -14,7 +14,7 @@
|
||||
</createTable>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="2020-05-25--001-users_courses" author="stvort">
|
||||
<changeSet id="2020-05-25--003-users_courses" author="stvort">
|
||||
<createTable tableName="users_courses">
|
||||
<column name="user_id" type="bigint">
|
||||
<constraints nullable="false"
|
||||
+1
-1
@@ -21,7 +21,7 @@ databaseChangeLog:
|
||||
runOnChange: true
|
||||
loadUpdateData:
|
||||
primaryKey: id
|
||||
file: data/2020-05-25--0002-users.csv
|
||||
file: data/2020-05-25--0002-users-avatars.csv
|
||||
relativeToChangelogFile: true
|
||||
separator: ;
|
||||
quotChar: '"'
|
||||
|
||||
+1
-1
@@ -10,5 +10,5 @@ values (1, 'Разработчик Java'),
|
||||
--changeset stvort:2020-05-25-002-users-courses
|
||||
insert into users_courses (user_id, course_id)
|
||||
values (1, 1), (1, 2), (1, 3), (1, 4),
|
||||
(2, 1), (2, 2), (1, 3),
|
||||
(2, 1), (2, 2), (2, 3),
|
||||
(3, 3), (3, 4)
|
||||
Reference in New Issue
Block a user