DevShaded
DevShaded
Explore posts from servers
DTDrizzle Team
Created by DevShaded on 8/18/2024 in #help
TypeError: Cannot read properties of undefined (reading 'dialect')
Hello, I am trying out Drizzle for the first time with javascript and Nodejs. I am trying out the migration part of Drizzle and I have setup everything that the docs said to me. But when I run node db/migrate.js I get the error undefined (reading 'dialect'). Why is this?
// config
import { defineConfig } from 'drizzle-kit';
export default defineConfig({
schema: './db/schema.js',
out: './drizzle',
dialect: 'mysql', // 'postgresql' | 'mysql' | 'sqlite'
dbCredentials: {
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
},
});
// config
import { defineConfig } from 'drizzle-kit';
export default defineConfig({
schema: './db/schema.js',
out: './drizzle',
dialect: 'mysql', // 'postgresql' | 'mysql' | 'sqlite'
dbCredentials: {
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
},
});
// db.js
const { drizzle } = require('drizzle-orm/mysql2');
const mysql = require('mysql2/promise');
const schema = require('./schema');

module.exports = connection = mysql.createConnection({
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
multipleStatements: true,
});

module.exports = db = drizzle(connection, { schema, mode: 'default' });
// db.js
const { drizzle } = require('drizzle-orm/mysql2');
const mysql = require('mysql2/promise');
const schema = require('./schema');

module.exports = connection = mysql.createConnection({
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
multipleStatements: true,
});

module.exports = db = drizzle(connection, { schema, mode: 'default' });
// migrate.js
require('dotenv').config();
const migrate = require('drizzle-orm/mysql2/migrator').migrate;
const { db, connection } = require('./db');

async function main() {
await migrate(db, { migrationsFolder: './drizzle' });
await connection.end();
}

main().catch(console.error);
// migrate.js
require('dotenv').config();
const migrate = require('drizzle-orm/mysql2/migrator').migrate;
const { db, connection } = require('./db');

async function main() {
await migrate(db, { migrationsFolder: './drizzle' });
await connection.end();
}

main().catch(console.error);
1 replies
FFilament
Created by DevShaded on 8/12/2024 in #❓┊help
Store additional data after form submition
Hello, I have this table called student_expenses that is linked to the lessons table. After I submit data to the lessons resource form, I want to add data from the form to the student_expenses. How can I achieve this?
1 replies
FFilament
Created by DevShaded on 8/12/2024 in #❓┊help
Change tab name for the relation managers
No description
4 replies