MateW
DTDrizzle Team
•Created by MateW on 7/26/2023 in #help
Error: relation "offers_details" does not exist
It seems like
drizzle
simple doesn't trigger CREATE TABLE
:/
Is that intended?5 replies
DTDrizzle Team
•Created by MateW on 7/26/2023 in #help
Error: relation "offers_details" does not exist
offerDetails.test.ts
import { describe, test, expect, vi, beforeEach } from 'vitest';
import { sql } from 'drizzle-orm';
import { db } from '../database.js';
import { offerDetails } from '../schema/index.js';
const record = {
url: "https://www.example.com/",
title: "Mock title",
description: "Mock description",
price: 100,
currency: "EUR",
area: 82.1,
additionalParameters: {},
rawResponse: "Mock raw response",
createDate: new Date(),
updateDate: new Date(),
}
describe('OfferDetails schema', () => {
test('should create OfferDetails item', async () => {
await db.select().from(offerDetails);
await expect(db.select().from(offerDetails)).resolves.toEqual(record);
});
});
import { describe, test, expect, vi, beforeEach } from 'vitest';
import { sql } from 'drizzle-orm';
import { db } from '../database.js';
import { offerDetails } from '../schema/index.js';
const record = {
url: "https://www.example.com/",
title: "Mock title",
description: "Mock description",
price: 100,
currency: "EUR",
area: 82.1,
additionalParameters: {},
rawResponse: "Mock raw response",
createDate: new Date(),
updateDate: new Date(),
}
describe('OfferDetails schema', () => {
test('should create OfferDetails item', async () => {
await db.select().from(offerDetails);
await expect(db.select().from(offerDetails)).resolves.toEqual(record);
});
});
5 replies
DTDrizzle Team
•Created by MateW on 7/26/2023 in #help
Error: relation "offers_details" does not exist
database.ts
import { drizzle } from 'drizzle-orm/node-postgres';
import { Pool } from 'pg';
import * as schema from './schema/index.js';
const pool = new Pool({
host: 'localhost',
port: 5432,
user: process.env.POSTGRES_USER,
password: process.env.POSTGRES_PASSWORD,
database: process.env.POSTGRES_DB,
});
export const db = drizzle(pool, { schema: { ...schema }, logger: true });
import { drizzle } from 'drizzle-orm/node-postgres';
import { Pool } from 'pg';
import * as schema from './schema/index.js';
const pool = new Pool({
host: 'localhost',
port: 5432,
user: process.env.POSTGRES_USER,
password: process.env.POSTGRES_PASSWORD,
database: process.env.POSTGRES_DB,
});
export const db = drizzle(pool, { schema: { ...schema }, logger: true });
5 replies
DTDrizzle Team
•Created by MateW on 7/26/2023 in #help
Error: relation "offers_details" does not exist
./schema/index.js
import {
numeric,
pgTable,
jsonb,
serial,
timestamp,
varchar,
} from 'drizzle-orm/pg-core';
import { InferModel } from 'drizzle-orm';
export const offerDetails = pgTable('offer_details', {
id: serial('id').primaryKey(),
url: varchar('url').notNull(),
title: varchar('title').notNull(),
description: varchar('description').notNull(),
price: numeric('price', { precision: 20, scale: 2 }).notNull(),
currency: varchar('currency', { length: 8 }).default('PLN').notNull(),
area: numeric('area', { precision: 20, scale: 2 }).notNull(),
additionalParameters: jsonb('additionalParameters'),
rawResponse: varchar('rawResponse').notNull(),
createDate: timestamp('createDate').notNull(),
modificationDate: timestamp('modificationDate').notNull(),
});
import {
numeric,
pgTable,
jsonb,
serial,
timestamp,
varchar,
} from 'drizzle-orm/pg-core';
import { InferModel } from 'drizzle-orm';
export const offerDetails = pgTable('offer_details', {
id: serial('id').primaryKey(),
url: varchar('url').notNull(),
title: varchar('title').notNull(),
description: varchar('description').notNull(),
price: numeric('price', { precision: 20, scale: 2 }).notNull(),
currency: varchar('currency', { length: 8 }).default('PLN').notNull(),
area: numeric('area', { precision: 20, scale: 2 }).notNull(),
additionalParameters: jsonb('additionalParameters'),
rawResponse: varchar('rawResponse').notNull(),
createDate: timestamp('createDate').notNull(),
modificationDate: timestamp('modificationDate').notNull(),
});
5 replies