NeonN
Neon2y ago
31 replies
sad-indigo

Creating a TimescaleDB Hypertable

Hi y'all, I'm creating a prisma migration for an existing table on Neon
-- This is an empty migration.

-- Enable TimescaleDB
CREATE EXTENSION IF NOT EXISTS timescaledb;


-- Add TimescaleDB-specific commands below
SELECT create_hypertable('"FundHistory"', '"createdAt"', migrate_data => true);

-- Enable compression
ALTER TABLE '"FundHistory"' SET (timescaledb.compress, timescaledb.compress_segmentby = 'fundId');

-- Add a compression policy
SELECT add_compression_policy('"FundHistory"', INTERVAL '7 days');


the prisma schema is
// Tracks the history for a Fund account
model FundHistory {
  id              BigInt  @id @default(autoincrement())
  createdAt       DateTime? @default(now())
  status          Json
  nav             Decimal
  fundId String  @map("fund_id")
  strategyId BigInt  @map("strategy_id") @default(0)

  fund  Fund @relation(fields: [fundId], references: [id])
}


I'm getting a column ""createdAt"" does not exist

What am I missing??
image.png
Was this page helpful?