-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: Remove 0.8 caps and add account delegation to the service (#123)
- Loading branch information
1 parent
09e1129
commit 878f8c9
Showing
49 changed files
with
1,270 additions
and
831 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
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { escapeSQLiteIdentifier } from '@databases/escape-identifier' | ||
import sql from '@databases/sql' | ||
import path from 'path' | ||
import { fileURLToPath } from 'url' | ||
|
||
const __dirname = path.dirname(fileURLToPath(import.meta.url)) | ||
|
||
/** @type {import('@databases/sql').FormatConfig} */ | ||
const sqliteFormat = { | ||
escapeIdentifier: (str) => escapeSQLiteIdentifier(str), | ||
formatValue: (value) => ({ placeholder: '?', value }), | ||
} | ||
|
||
const migrations = [sql.file(`${__dirname}/tables.sql`)] | ||
|
||
/** | ||
* Probably should batch queries and use https://www.atdatabases.org/docs/split-sql-query to split inlined queries | ||
* | ||
* @see https://docs.google.com/document/d/1QpUryGBWaGbAIjkw2URwpV6Btp5S-XQVkBJJs85dLRc/edit# | ||
* | ||
* @param {D1Database} db | ||
*/ | ||
export async function migrate(db) { | ||
try { | ||
for (const m of migrations) { | ||
await db.exec(m.format(sqliteFormat).text.replace(/\n/g, '')) | ||
} | ||
} catch (error) { | ||
const err = /** @type {Error} */ (error) | ||
// eslint-disable-next-line no-console | ||
console.log({ | ||
message: err.message, | ||
// @ts-ignore | ||
cause: err.cause?.message, | ||
}) | ||
} | ||
} |
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,2 @@ | ||
DROP TABLE | ||
IF EXISTS accounts; |
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 |
---|---|---|
@@ -1,11 +1,10 @@ | ||
DROP TABLE IF EXISTS accounts; | ||
|
||
CREATE TABLE accounts ( | ||
did TEXT NOT NULL PRIMARY KEY | ||
, product TEXT NOT NULL | ||
, email TEXT NOT NULL | ||
, agent TEXT NOT NULL | ||
, inserted_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')) | ||
, updated_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')) | ||
, UNIQUE(did) | ||
) | ||
CREATE TABLE | ||
IF NOT EXISTS accounts ( | ||
did TEXT NOT NULL PRIMARY KEY, | ||
product TEXT NOT NULL, | ||
email TEXT NOT NULL, | ||
agent TEXT NOT NULL, | ||
inserted_at TEXT NOT NULL DEFAULT (strftime ('%Y-%m-%dT%H:%M:%fZ', 'now')), | ||
updated_at TEXT NOT NULL DEFAULT (strftime ('%Y-%m-%dT%H:%M:%fZ', 'now')), | ||
UNIQUE (did) | ||
) |
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
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
Oops, something went wrong.