Skip to content

Commit

Permalink
add missing json column @ Getting Started.
Browse files Browse the repository at this point in the history
  • Loading branch information
igalklebanov committed Oct 3, 2024
1 parent 9b746b8 commit 611eb0c
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions site/docs/getting-started/Summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ import Admonition from '@theme/Admonition'
import CodeBlock from '@theme/CodeBlock'
import Link from '@docusaurus/Link'
import { IUseADifferentDatabase } from './IUseADifferentDatabase'
import {
PRETTY_DIALECT_NAMES,
type Dialect,
type PropsWithDialect,
} from './shared'
import { type Dialect, type PropsWithDialect } from './shared'

const dialectSpecificCodeSnippets: Record<Dialect, string> = {
postgresql: ` await db.schema.createTable('person')
Expand All @@ -17,6 +13,7 @@ const dialectSpecificCodeSnippets: Record<Dialect, string> = {
.addColumn('created_at', 'timestamp', (cb) =>
cb.notNull().defaultTo(sql\`now()\`)
)
.addColumn('metadata', 'jsonb', (cb) => cb.notNull())
.execute()`,
mysql: ` await db.schema.createTable('person')
.addColumn('id', 'integer', (cb) => cb.primaryKey().autoIncrement())
Expand All @@ -26,6 +23,7 @@ const dialectSpecificCodeSnippets: Record<Dialect, string> = {
.addColumn('created_at', 'timestamp', (cb) =>
cb.notNull().defaultTo(sql\`now()\`)
)
.addColumn('metadata', 'json', (cb) => cb.notNull())
.execute()`,
// TODO: Update line 42's IDENTITY once identity(1,1) is added to core.
mssql: ` await db.schema.createTable('person')
Expand All @@ -36,6 +34,7 @@ const dialectSpecificCodeSnippets: Record<Dialect, string> = {
.addColumn('created_at', 'datetime', (cb) =>
cb.notNull().defaultTo(sql\`GETDATE()\`)
)
.addColumn('metadata', sql\`nvarchar(max)\`, (cb) => cb.notNull())
.execute()`,
sqlite: ` await db.schema.createTable('person')
.addColumn('id', 'integer', (cb) => cb.primaryKey().autoIncrement().notNull())
Expand All @@ -45,6 +44,7 @@ const dialectSpecificCodeSnippets: Record<Dialect, string> = {
.addColumn('created_at', 'timestamp', (cb) =>
cb.notNull().defaultTo(sql\`current_timestamp\`)
)
.addColumn('metadata', 'text', (cb) => cb.notNull())
.execute()`,
}

Expand Down Expand Up @@ -107,6 +107,12 @@ ${dialectSpecificCodeSnippet}
first_name: 'Jennifer',
last_name: 'Aniston',
gender: 'woman',
metadata: sql.valJson({
login_at: new Date().toISOString(),
ip: null,
agent: null,
plan: 'free',
}),
})
})
Expand Down

0 comments on commit 611eb0c

Please sign in to comment.