-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create initial migration #57
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
-- CreateTable | ||
CREATE TABLE "Event" ( | ||
"observedTimestamp" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"blockNumber" INTEGER NOT NULL, | ||
"logIndex" INTEGER NOT NULL, | ||
"blockHash" BLOB NOT NULL, | ||
"txHash" BLOB NOT NULL, | ||
"topic1" BLOB, | ||
"topic2" BLOB, | ||
"topic3" BLOB, | ||
"data" BLOB NOT NULL, | ||
"emittedTimestamp" DATETIME, | ||
"lockedTimestamp" DATETIME, | ||
"abiHash" BLOB NOT NULL, | ||
"sourceAddress" BLOB NOT NULL, | ||
|
||
PRIMARY KEY ("blockNumber", "logIndex"), | ||
CONSTRAINT "Event_sourceAddress_abiHash_fkey" FOREIGN KEY ("sourceAddress", "abiHash") REFERENCES "EventSource" ("address", "abiHash") ON DELETE RESTRICT ON UPDATE CASCADE, | ||
CONSTRAINT "Event_abiHash_fkey" FOREIGN KEY ("abiHash") REFERENCES "EventAbi" ("hash") ON DELETE RESTRICT ON UPDATE CASCADE | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "ObservedLog" ( | ||
"blockNumber" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "BlockProcessError" ( | ||
"blockNumber" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "FailedUrl" ( | ||
"blockNumber" INTEGER NOT NULL, | ||
"logIndex" INTEGER NOT NULL, | ||
"url" TEXT NOT NULL, | ||
|
||
PRIMARY KEY ("blockNumber", "logIndex", "url"), | ||
CONSTRAINT "FailedUrl_blockNumber_logIndex_fkey" FOREIGN KEY ("blockNumber", "logIndex") REFERENCES "Event" ("blockNumber", "logIndex") ON DELETE RESTRICT ON UPDATE CASCADE | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "EventAbi" ( | ||
"hash" BLOB NOT NULL PRIMARY KEY, | ||
"json" TEXT NOT NULL | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "EventSource" ( | ||
"address" BLOB NOT NULL, | ||
"abiHash" BLOB NOT NULL, | ||
|
||
PRIMARY KEY ("address", "abiHash"), | ||
CONSTRAINT "EventSource_abiHash_fkey" FOREIGN KEY ("abiHash") REFERENCES "EventAbi" ("hash") ON DELETE RESTRICT ON UPDATE CASCADE | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "EmitDestination" ( | ||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, | ||
"sourceAddress" BLOB NOT NULL, | ||
"abiHash" BLOB NOT NULL, | ||
"webhookUrl" TEXT NOT NULL, | ||
"topic1" BLOB, | ||
"topic2" BLOB, | ||
"topic3" BLOB, | ||
CONSTRAINT "EmitDestination_sourceAddress_abiHash_fkey" FOREIGN KEY ("sourceAddress", "abiHash") REFERENCES "EventSource" ("address", "abiHash") ON DELETE RESTRICT ON UPDATE CASCADE | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "User" ( | ||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, | ||
"email" TEXT NOT NULL, | ||
"password" TEXT NOT NULL | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Permission" ( | ||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, | ||
"userId" INTEGER NOT NULL, | ||
"type" TEXT NOT NULL, | ||
"abiHash" BLOB, | ||
"sourceAddress" BLOB, | ||
"destinationId" INTEGER, | ||
CONSTRAINT "Permission_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE, | ||
CONSTRAINT "Permission_abiHash_fkey" FOREIGN KEY ("abiHash") REFERENCES "EventAbi" ("hash") ON DELETE CASCADE ON UPDATE CASCADE, | ||
CONSTRAINT "Permission_abiHash_sourceAddress_fkey" FOREIGN KEY ("abiHash", "sourceAddress") REFERENCES "EventSource" ("abiHash", "address") ON DELETE CASCADE ON UPDATE CASCADE, | ||
CONSTRAINT "Permission_destinationId_fkey" FOREIGN KEY ("destinationId") REFERENCES "EmitDestination" ("id") ON DELETE CASCADE ON UPDATE CASCADE | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "EmitDestination_sourceAddress_abiHash_webhookUrl_topic1_topic2_topic3_key" ON "EmitDestination"("sourceAddress", "abiHash", "webhookUrl", "topic1", "topic2", "topic3"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); |
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,3 @@ | ||
# Please do not edit this file manually | ||
# It should be added in your version-control system (i.e. Git) | ||
provider = "sqlite" | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would migration work when provider changed to postgres?
(+ eof line?)