This repository has been archived by the owner on Sep 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 863
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
197 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
...-mysql/src/test/scala/com/prisma/integration/ChangingFromRelationToScalarOrBackSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
package com.prisma.integration | ||
|
||
import org.scalatest.{FlatSpec, Matchers} | ||
|
||
class ChangingFromRelationToScalarOrBackSpec extends FlatSpec with Matchers with IntegrationBaseSpec { | ||
|
||
"Changing a field from scalar to relation" should "work when there is no data yet" in { | ||
|
||
val schema = | ||
"""type A { | ||
| a: String! @unique | ||
| b: String | ||
|} | ||
| | ||
|type B { | ||
| b: String! @unique | ||
|}""" | ||
|
||
val (project, _) = setupProject(schema) | ||
|
||
val schema1 = | ||
"""type A { | ||
| a: String! @unique | ||
| b: B | ||
|} | ||
| | ||
|type B { | ||
| b: String! @unique | ||
|}""" | ||
|
||
deployServer.deploySchema(project, schema1) | ||
} | ||
|
||
"Changing a field from scalar to relation" should "work when there is already data and should delete the old column" in { | ||
|
||
val schema = | ||
"""type A { | ||
| a: String! @unique | ||
| b: String | ||
|} | ||
| | ||
|type B { | ||
| b: String! @unique | ||
|}""" | ||
|
||
val (project, _) = setupProject(schema) | ||
|
||
apiServer.query("""mutation{createA(data:{a:"A", b: "B"}){a}}""", project) | ||
|
||
val as = apiServer.query("""{as{a}}""", project) | ||
as.toString should be("""{"data":{"as":[{"a":"A"}]}}""") | ||
|
||
val schema1 = | ||
"""type A { | ||
| a: String! @unique | ||
| b: B | ||
|} | ||
| | ||
|type B { | ||
| b: String! @unique | ||
|}""" | ||
|
||
deployServer.deploySchemaThatMustWarn(project, schema1, force = true) | ||
} | ||
|
||
"Changing a relation to scalar" should "work when there is no data yet" in { | ||
|
||
val schema = | ||
"""type A { | ||
| a: String! @unique | ||
| b: B | ||
|} | ||
| | ||
|type B { | ||
| b: String! @unique | ||
|}""" | ||
|
||
val (project, _) = setupProject(schema) | ||
|
||
val schema1 = | ||
"""type A { | ||
| a: String! @unique | ||
| b: String | ||
|} | ||
| | ||
|type B { | ||
| b: String! @unique | ||
|}""" | ||
|
||
deployServer.deploySchema(project, schema1) | ||
} | ||
|
||
"Changing a relation to scalar" should "work when there is already data" in { | ||
|
||
val schema = | ||
"""type A { | ||
| a: String! @unique | ||
| b: B | ||
|} | ||
| | ||
|type B { | ||
| b: String! @unique | ||
|}""" | ||
|
||
val (project, _) = setupProject(schema) | ||
|
||
apiServer.query("""mutation{createA(data:{a:"A", b: {b: "B"}}){a}}""", project) | ||
|
||
val as = apiServer.query("""{as{a, b{b}}}""", project) | ||
as.toString should be("""{"data":{"as":[{"a":"A","b":{"b":"B"}}]}}""") | ||
|
||
val schema1 = | ||
"""type A { | ||
| a: String! @unique | ||
| b: String | ||
|} | ||
| | ||
|type B { | ||
| b: String! @unique | ||
|}""" | ||
|
||
deployServer.deploySchema(project, schema1) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters