-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Support table-only mode * remove fields from models in table only mode * Add @ripry as a contributor Co-authored-by: John Fay <[email protected]>
- Loading branch information
Showing
7 changed files
with
125 additions
and
20 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
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 |
---|---|---|
|
@@ -7,3 +7,4 @@ | |
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings | ||
|
||
DATABASE_URL="postgresql://johndoe:[email protected]:6543/mydb?schema=public" | ||
ERD_DEBUG=true |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,34 @@ | ||
import * as child_process from 'child_process'; | ||
|
||
test('table-only.prisma', async () => { | ||
const fileName = 'TableOnly.svg'; | ||
const folderName = '__tests__'; | ||
child_process.execSync(`rm -f ${folderName}/${fileName}`); | ||
child_process.execSync( | ||
`npx prisma generate --schema ./prisma/table-only.prisma` | ||
); | ||
const listFile = child_process.execSync(`ls -la ${folderName}/${fileName}`); | ||
// did it generate a file | ||
expect(listFile.toString()).toContain(fileName); | ||
|
||
const svgAsString = child_process | ||
.execSync(`cat ${folderName}/${fileName}`) | ||
.toString(); | ||
|
||
// did it generate a file without enum | ||
expect(svgAsString).toContain(`<svg`); | ||
// include tables | ||
expect(svgAsString).toContain(`Booking`); | ||
expect(svgAsString).toContain(`Event`); | ||
// exclude enums | ||
expect(svgAsString).not.toContain(`PENDING`); | ||
expect(svgAsString).not.toContain(`CONFIRMED`); | ||
expect(svgAsString).not.toContain(`CANCELLED`); | ||
// exclude table columns | ||
expect(svgAsString).not.toContain(`name`); | ||
expect(svgAsString).not.toContain(`startDate`); | ||
expect(svgAsString).not.toContain(`status`); | ||
expect(svgAsString).not.toContain(`inviteeEmail`); | ||
expect(svgAsString).not.toContain(`startDateUTC`); | ||
expect(svgAsString).not.toContain(`cancelCode`); | ||
}); |
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,36 @@ | ||
// This is your Prisma schema file, | ||
// learn more about it in the docs: https://pris.ly/d/prisma-schema | ||
|
||
datasource db { | ||
provider = "postgresql" | ||
url = env("DATABASE_URL") | ||
} | ||
|
||
generator erd { | ||
provider = "node ./dist/index.js" | ||
output = "../__tests__/TableOnly.svg" | ||
theme = "forest" | ||
tableOnly = true | ||
} | ||
|
||
model Booking { | ||
id Int @id @default(autoincrement()) | ||
inviteeEmail String | ||
startDateUTC DateTime | ||
cancelCode String | ||
events Event[] | ||
} | ||
|
||
model Event { | ||
id Int @id @default(autoincrement()) | ||
name String | ||
startDate DateTime | ||
bookings Booking[] | ||
status Status @default(PENDING) | ||
} | ||
|
||
enum Status { | ||
PENDING | ||
CANCELLED | ||
CONFIRMED | ||
} |
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