@indexfolio/db 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +3 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +51 -0
- package/prisma/migrations/20260530144627/migration.sql +100 -0
- package/prisma/migrations/20260604160801_add_isin_ticker_unique/migration.sql +11 -0
- package/prisma/migrations/20260606211527_remove_redundant_indexes/migration.sql +5 -0
- package/prisma/migrations/migration_lock.toml +3 -0
- package/prisma/schema.prisma +85 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@prisma/client';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@prisma/client';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
|
|
17
|
+
// src/index.ts
|
|
18
|
+
var index_exports = {};
|
|
19
|
+
module.exports = __toCommonJS(index_exports);
|
|
20
|
+
__reExport(index_exports, require("@prisma/client"), module.exports);
|
|
21
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
22
|
+
0 && (module.exports = {
|
|
23
|
+
...require("@prisma/client")
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// The single entry point for database access. Re-exports the generated Prisma\n// client and every model type, so the rest of the codebase imports from\n// '@indexfolio/db' and never touches '@prisma/client' directly.\nexport * from '@prisma/client'\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAGA,0BAAc,2BAHd;","names":[]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// The single entry point for database access. Re-exports the generated Prisma\n// client and every model type, so the rest of the codebase imports from\n// '@indexfolio/db' and never touches '@prisma/client' directly.\nexport * from '@prisma/client'\n"],"mappings":";AAGA,cAAc;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@indexfolio/db",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Prisma schema, migrations, and typed client for Indexfolio.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/aravindasiva/indexfolio.git",
|
|
9
|
+
"directory": "packages/db"
|
|
10
|
+
},
|
|
11
|
+
"main": "./dist/index.js",
|
|
12
|
+
"module": "./dist/index.mjs",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"import": "./dist/index.mjs",
|
|
18
|
+
"require": "./dist/index.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"prisma/schema.prisma",
|
|
24
|
+
"prisma/migrations"
|
|
25
|
+
],
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsup",
|
|
31
|
+
"typecheck": "tsc --noEmit",
|
|
32
|
+
"lint": "eslint src",
|
|
33
|
+
"generate": "prisma generate",
|
|
34
|
+
"migrate:deploy": "prisma migrate deploy",
|
|
35
|
+
"migrate:dev": "prisma migrate dev",
|
|
36
|
+
"reset": "prisma migrate reset --force",
|
|
37
|
+
"seed": "prisma db seed",
|
|
38
|
+
"studio": "prisma studio",
|
|
39
|
+
"postinstall": "prisma generate"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@prisma/client": "^6.0.0",
|
|
43
|
+
"prisma": "^6.0.0"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/node": "^24.0.0",
|
|
47
|
+
"tsup": "^8.0.0",
|
|
48
|
+
"tsx": "^4.22.4",
|
|
49
|
+
"typescript": "~5.7.0"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
-- CreateTable
|
|
2
|
+
CREATE TABLE "ETF" (
|
|
3
|
+
"id" TEXT NOT NULL,
|
|
4
|
+
"ticker" TEXT NOT NULL,
|
|
5
|
+
"isin" TEXT NOT NULL,
|
|
6
|
+
"name" TEXT NOT NULL,
|
|
7
|
+
"domicile" TEXT NOT NULL,
|
|
8
|
+
"exchange" TEXT NOT NULL,
|
|
9
|
+
"currency" TEXT NOT NULL,
|
|
10
|
+
"ter" DECIMAL(65,30) NOT NULL,
|
|
11
|
+
"fundSizeEur" BIGINT NOT NULL,
|
|
12
|
+
"isAccumulating" BOOLEAN NOT NULL,
|
|
13
|
+
"isUcits" BOOLEAN NOT NULL,
|
|
14
|
+
"indexTracked" TEXT NOT NULL,
|
|
15
|
+
"assetClass" TEXT NOT NULL,
|
|
16
|
+
"provider" TEXT NOT NULL,
|
|
17
|
+
"inceptionDate" TIMESTAMP(3) NOT NULL,
|
|
18
|
+
"kiidUrl" TEXT,
|
|
19
|
+
"lastMetadataSync" TIMESTAMP(3),
|
|
20
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
21
|
+
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
22
|
+
|
|
23
|
+
CONSTRAINT "ETF_pkey" PRIMARY KEY ("id")
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
-- CreateTable
|
|
27
|
+
CREATE TABLE "Holding" (
|
|
28
|
+
"id" TEXT NOT NULL,
|
|
29
|
+
"etfId" TEXT NOT NULL,
|
|
30
|
+
"ticker" TEXT NOT NULL,
|
|
31
|
+
"name" TEXT NOT NULL,
|
|
32
|
+
"weight" DECIMAL(65,30) NOT NULL,
|
|
33
|
+
"country" TEXT NOT NULL,
|
|
34
|
+
"sector" TEXT NOT NULL,
|
|
35
|
+
"asOfDate" TIMESTAMP(3) NOT NULL,
|
|
36
|
+
|
|
37
|
+
CONSTRAINT "Holding_pkey" PRIMARY KEY ("id")
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
-- CreateTable
|
|
41
|
+
CREATE TABLE "Price" (
|
|
42
|
+
"id" TEXT NOT NULL,
|
|
43
|
+
"etfId" TEXT NOT NULL,
|
|
44
|
+
"date" TIMESTAMP(3) NOT NULL,
|
|
45
|
+
"close" DECIMAL(65,30) NOT NULL,
|
|
46
|
+
"currency" TEXT NOT NULL,
|
|
47
|
+
|
|
48
|
+
CONSTRAINT "Price_pkey" PRIMARY KEY ("id")
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
-- CreateTable
|
|
52
|
+
CREATE TABLE "ExchangeRate" (
|
|
53
|
+
"id" TEXT NOT NULL,
|
|
54
|
+
"date" TIMESTAMP(3) NOT NULL,
|
|
55
|
+
"fromCurrency" TEXT NOT NULL,
|
|
56
|
+
"toCurrency" TEXT NOT NULL,
|
|
57
|
+
"rate" DECIMAL(65,30) NOT NULL,
|
|
58
|
+
|
|
59
|
+
CONSTRAINT "ExchangeRate_pkey" PRIMARY KEY ("id")
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
-- CreateTable
|
|
63
|
+
CREATE TABLE "PipelineRun" (
|
|
64
|
+
"id" TEXT NOT NULL,
|
|
65
|
+
"pipeline" TEXT NOT NULL,
|
|
66
|
+
"status" TEXT NOT NULL,
|
|
67
|
+
"startedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
68
|
+
"completedAt" TIMESTAMP(3),
|
|
69
|
+
"errorMessage" TEXT,
|
|
70
|
+
"recordsProcessed" INTEGER,
|
|
71
|
+
|
|
72
|
+
CONSTRAINT "PipelineRun_pkey" PRIMARY KEY ("id")
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
-- CreateIndex
|
|
76
|
+
CREATE UNIQUE INDEX "ETF_ticker_key" ON "ETF"("ticker");
|
|
77
|
+
|
|
78
|
+
-- CreateIndex
|
|
79
|
+
CREATE UNIQUE INDEX "ETF_isin_key" ON "ETF"("isin");
|
|
80
|
+
|
|
81
|
+
-- CreateIndex
|
|
82
|
+
CREATE INDEX "Holding_etfId_asOfDate_idx" ON "Holding"("etfId", "asOfDate");
|
|
83
|
+
|
|
84
|
+
-- CreateIndex
|
|
85
|
+
CREATE INDEX "Price_etfId_date_idx" ON "Price"("etfId", "date");
|
|
86
|
+
|
|
87
|
+
-- CreateIndex
|
|
88
|
+
CREATE UNIQUE INDEX "Price_etfId_date_key" ON "Price"("etfId", "date");
|
|
89
|
+
|
|
90
|
+
-- CreateIndex
|
|
91
|
+
CREATE INDEX "ExchangeRate_date_fromCurrency_toCurrency_idx" ON "ExchangeRate"("date", "fromCurrency", "toCurrency");
|
|
92
|
+
|
|
93
|
+
-- CreateIndex
|
|
94
|
+
CREATE UNIQUE INDEX "ExchangeRate_date_fromCurrency_toCurrency_key" ON "ExchangeRate"("date", "fromCurrency", "toCurrency");
|
|
95
|
+
|
|
96
|
+
-- AddForeignKey
|
|
97
|
+
ALTER TABLE "Holding" ADD CONSTRAINT "Holding_etfId_fkey" FOREIGN KEY ("etfId") REFERENCES "ETF"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
98
|
+
|
|
99
|
+
-- AddForeignKey
|
|
100
|
+
ALTER TABLE "Price" ADD CONSTRAINT "Price_etfId_fkey" FOREIGN KEY ("etfId") REFERENCES "ETF"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Warnings:
|
|
3
|
+
|
|
4
|
+
- A unique constraint covering the columns `[isin,ticker]` on the table `ETF` will be added. If there are existing duplicate values, this will fail.
|
|
5
|
+
|
|
6
|
+
*/
|
|
7
|
+
-- DropIndex
|
|
8
|
+
DROP INDEX "ETF_isin_key";
|
|
9
|
+
|
|
10
|
+
-- CreateIndex
|
|
11
|
+
CREATE UNIQUE INDEX "ETF_isin_ticker_key" ON "ETF"("isin", "ticker");
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// Prisma schema for Indexfolio
|
|
2
|
+
// Datasource: Neon Postgres (local Docker for dev)
|
|
3
|
+
// Generator: Prisma Client JS
|
|
4
|
+
|
|
5
|
+
datasource db {
|
|
6
|
+
provider = "postgresql"
|
|
7
|
+
url = env("DATABASE_URL")
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// Build the Prisma engine for the local OS and for Debian (the Docker runtime).
|
|
11
|
+
generator client {
|
|
12
|
+
provider = "prisma-client-js"
|
|
13
|
+
binaryTargets = ["native", "debian-openssl-3.0.x"]
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
model ETF {
|
|
17
|
+
id String @id @default(cuid())
|
|
18
|
+
ticker String @unique
|
|
19
|
+
isin String
|
|
20
|
+
name String
|
|
21
|
+
domicile String
|
|
22
|
+
exchange String
|
|
23
|
+
currency String
|
|
24
|
+
ter Decimal
|
|
25
|
+
fundSizeEur BigInt
|
|
26
|
+
isAccumulating Boolean
|
|
27
|
+
isUcits Boolean
|
|
28
|
+
indexTracked String
|
|
29
|
+
assetClass String
|
|
30
|
+
provider String
|
|
31
|
+
inceptionDate DateTime
|
|
32
|
+
kiidUrl String?
|
|
33
|
+
lastMetadataSync DateTime?
|
|
34
|
+
createdAt DateTime @default(now())
|
|
35
|
+
updatedAt DateTime @updatedAt
|
|
36
|
+
holdings Holding[]
|
|
37
|
+
prices Price[]
|
|
38
|
+
|
|
39
|
+
@@unique([isin, ticker])
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
model Holding {
|
|
43
|
+
id String @id @default(cuid())
|
|
44
|
+
etfId String
|
|
45
|
+
etf ETF @relation(fields: [etfId], references: [id])
|
|
46
|
+
ticker String
|
|
47
|
+
name String
|
|
48
|
+
weight Decimal
|
|
49
|
+
country String
|
|
50
|
+
sector String
|
|
51
|
+
asOfDate DateTime
|
|
52
|
+
|
|
53
|
+
@@index([etfId, asOfDate])
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
model Price {
|
|
57
|
+
id String @id @default(cuid())
|
|
58
|
+
etfId String
|
|
59
|
+
etf ETF @relation(fields: [etfId], references: [id])
|
|
60
|
+
date DateTime
|
|
61
|
+
close Decimal
|
|
62
|
+
currency String
|
|
63
|
+
|
|
64
|
+
@@unique([etfId, date])
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
model ExchangeRate {
|
|
68
|
+
id String @id @default(cuid())
|
|
69
|
+
date DateTime
|
|
70
|
+
fromCurrency String
|
|
71
|
+
toCurrency String
|
|
72
|
+
rate Decimal
|
|
73
|
+
|
|
74
|
+
@@unique([date, fromCurrency, toCurrency])
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
model PipelineRun {
|
|
78
|
+
id String @id @default(cuid())
|
|
79
|
+
pipeline String
|
|
80
|
+
status String
|
|
81
|
+
startedAt DateTime @default(now())
|
|
82
|
+
completedAt DateTime?
|
|
83
|
+
errorMessage String?
|
|
84
|
+
recordsProcessed Int?
|
|
85
|
+
}
|