Skip to content

Commit

Permalink
Merge pull request #20 from ucsb-cs156-f24/pc-addInDatabaseMigrations
Browse files Browse the repository at this point in the history
pc - add dependency for liquibase, latest version
  • Loading branch information
pconrad authored Oct 18, 2024
2 parents 27c9325 + a57c0ad commit 2272aeb
Show file tree
Hide file tree
Showing 9 changed files with 334 additions and 7 deletions.
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@
<version>2.5.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.liquibase/liquibase-maven-plugin -->
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>4.29.2</version>
</dependency>

</dependencies>

<!-- (24) <repositories/> -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Entity(name = "restaurant")
@Entity(name = "restaurants")
public class Restaurant {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down
11 changes: 5 additions & 6 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,19 @@ spring.security.oauth2.client.registration.google.client-id=${GOOGLE_CLIENT_ID:$
spring.security.oauth2.client.registration.google.client-secret=${GOOGLE_CLIENT_SECRET:${env.GOOGLE_CLIENT_SECRET:client_secret_unset}}
spring.security.oauth2.client.registration.google.scope=email,profile


springdoc.swagger-ui.tryItOutEnabled=true

# see: https://medium.com/@thecodinganalyst/configure-spring-security-csrf-for-testing-on-swagger-e9e6461ee0c1
springdoc.swagger-ui.csrf.enabled=true


management.endpoints.web.exposure.include=mappings
spring.jpa.hibernate.ddl-auto=update

app.admin.emails=${ADMIN_EMAILS:${env.ADMIN_EMAILS:phtcon@ucsb.edu}}

spring.mvc.pathmatch.matching-strategy = ANT_PATH_MATCHER
server.compression.enabled=false

spring.mvc.format.date-time=iso

app.oauth.login=${OAUTH_LOGIN:${env.OAUTH_LOGIN:/oauth2/authorization/google}}
app.oauth.login=${OAUTH_LOGIN:${env.OAUTH_LOGIN:/oauth2/authorization/google}}

spring.jpa.hibernate.ddl-auto=none
spring.liquibase.change-log=db/migration/changelog-master.json
5 changes: 5 additions & 0 deletions src/main/resources/db/migration/changelog-master.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{ "databaseChangeLog": [
{
"includeAll": {"path": "db/migration/changes/"}
}
]}
56 changes: 56 additions & 0 deletions src/main/resources/db/migration/changes/Restaurants.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"databaseChangeLog": [
{
"changeSet": {
"id": "Restaurants-1",
"author": "phtcon",
"preConditions": [
{
"onFail": "MARK_RAN"
},
{
"not": [
{
"tableExists": {
"tableName": "RESTAURANTS"
}
}
]
}
],
"changes": [
{
"createTable": {
"columns": [
{
"column": {
"autoIncrement": true,
"constraints": {
"primaryKey": true,
"primaryKeyName": "RESTAURANTS_PK"
},
"name": "ID",
"type": "BIGINT"
}
},
{
"column": {
"name": "NAME",
"type": "VARCHAR(255)"
}
},
{
"column": {
"name": "DESCRIPTION",
"type": "VARCHAR(255)"
}
}
],
"tableName": "RESTAURANTS"
}
}
]
}
}
]
}
62 changes: 62 additions & 0 deletions src/main/resources/db/migration/changes/UCSBDates.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"databaseChangeLog": [
{
"changeSet": {
"id": "UCSBDates-1",
"author": "MattP",
"preConditions": [
{
"onFail": "MARK_RAN"
},
{
"not": [
{
"tableExists": {
"tableName": "UCSBDATES"
}
}
]
}
],
"changes": [
{
"createTable": {
"columns": [
{
"column": {
"autoIncrement": true,
"constraints": {
"primaryKey": true,
"primaryKeyName": "CONSTRAINT_5"
},
"name": "ID",
"type": "BIGINT"
}
},
{
"column": {
"name": "LOCAL_DATE_TIME",
"type": "TIMESTAMP"
}
},
{
"column": {
"name": "NAME",
"type": "VARCHAR(255)"
}
},
{
"column": {
"name": "QUARTERYYYYQ",
"type": "VARCHAR(255)"
}
}
],
"tableName": "UCSBDATES"
}
}
]
}
}
]
}
86 changes: 86 additions & 0 deletions src/main/resources/db/migration/changes/UCSBDiningCommons.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{ "databaseChangeLog": [
{
"changeSet": {
"id": "UCSBDiningCommons-1",
"author": "MattP",
"preConditions": [
{
"onFail": "MARK_RAN"
},
{
"not": [
{
"tableExists": {
"tableName": "UCSBDININGCOMMONS"
}
}
]
}
],
"changes": [
{
"createTable": {
"columns": [
{
"column": {
"constraints": {
"primaryKey": true,
"primaryKeyName": "CONSTRAINT_2"
},
"name": "CODE",
"type": "VARCHAR(255)"
}
},
{
"column": {
"constraints": {
"nullable": false
},
"name": "HAS_DINING_CAM",
"type": "BOOLEAN"
}
},
{
"column": {
"constraints": {
"nullable": false
},
"name": "HAS_SACK_MEAL",
"type": "BOOLEAN"
}
},
{
"column": {
"constraints": {
"nullable": false
},
"name": "HAS_TAKE_OUT_MEAL",
"type": "BOOLEAN"
}
},
{
"column": {
"name": "LATITUDE",
"type": "DOUBLE(17)"
}
},
{
"column": {
"name": "LONGITUDE",
"type": "DOUBLE(17)"
}
},
{
"column": {
"name": "NAME",
"type": "VARCHAR(255)"
}
}]
,
"tableName": "UCSBDININGCOMMONS"
}
}]

}
}
]}
108 changes: 108 additions & 0 deletions src/main/resources/db/migration/changes/Users.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
{ "databaseChangeLog": [
{
"changeSet": {
"id": "Users-1",
"author": "MattP",
"preConditions": [
{
"onFail": "MARK_RAN"
},
{
"not": [
{
"tableExists": {
"tableName": "USERS"
}
}
]
}
],
"changes": [
{
"createTable": {
"columns": [
{
"column": {
"autoIncrement": true,
"constraints": {
"primaryKey": true,
"primaryKeyName": "CONSTRAINT_4"
},
"name": "ID",
"type": "BIGINT"
}
},
{
"column": {
"constraints": {
"nullable": false
},
"name": "ADMIN",
"type": "BOOLEAN"
}
},
{
"column": {
"name": "EMAIL",
"type": "VARCHAR(255)"
}
},
{
"column": {
"constraints": {
"nullable": false
},
"name": "EMAIL_VERIFIED",
"type": "BOOLEAN"
}
},
{
"column": {
"name": "FAMILY_NAME",
"type": "VARCHAR(255)"
}
},
{
"column": {
"name": "FULL_NAME",
"type": "VARCHAR(255)"
}
},
{
"column": {
"name": "GIVEN_NAME",
"type": "VARCHAR(255)"
}
},
{
"column": {
"name": "GOOGLE_SUB",
"type": "VARCHAR(255)"
}
},
{
"column": {
"name": "HOSTED_DOMAIN",
"type": "VARCHAR(255)"
}
},
{
"column": {
"name": "LOCALE",
"type": "VARCHAR(255)"
}
},
{
"column": {
"name": "PICTURE_URL",
"type": "VARCHAR(255)"
}
}]
,
"tableName": "USERS"
}
}]

}
}
]}
4 changes: 4 additions & 0 deletions src/main/resources/liquibase.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
url: jdbc:h2:file:./target/db-development
changeLogFile: db/migration/changelog-master.json
username: sa
password: password

0 comments on commit 2272aeb

Please sign in to comment.