feathersjs / feathers-chat

A Feathers real-time chat application
https://feathersjs.com
MIT License
511 stars 248 forks source link

Feathers Chat MySQl/MariaDB version #282

Closed Complexlity closed 1 year ago

Complexlity commented 1 year ago

Update: I have been able to completely port the feathers-chat from sqlite to MySQL. Plugging this here just incase anyone might need the same Feathers Chat MySQL Version

I am trying to port the feathers-chat-ts from the sqlite to use MySQl instead. But this always errors. I have updated the default.json, created mysql.ts and also updated the knexfile.js but this does not seem to work

Steps to reproduce

declare module './declarations' { interface Configuration { mysqlClient: Knex } }

export const mysql = (app: Application) => { const config = app.get('mysql') const db = knex(config!)

app.set('mysqlClient', db) }

- Update config/default.json. Remove `sqlite` property and replace with `mysql`

//config/default.json "mysql": { "client": "mysql", "connection": { "host": "", "port": , "user": "", "password": "", "database": "" } },

- Update knexfile.js. Get `mysql` from config rather than `sqlite`

//knexfile.ts // For more information about this file see https://dove.feathersjs.com/guides/cli/databases.html import { app } from './src/app'

// Load our database connection info from the app configuration const config = app.get('mysql')

module.exports = config

- Update app.ts to use MySQL rather than sqlite

//app.ts

import { mysql } from './mysql'

......

app.configure(mysql)


(First please check that this issue is not already solved as [described
here](https://github.com/feathersjs/feathers/blob/master/.github/contributing.md#report-a-bug))

- [ ] Tell us what broke. The more detailed the better.
- [ ] If you can, please create a simple example that reproduces the issue and link to a gist, jsbin, repo, etc.

### Expected behavior
Tell us what should happen
The feathers app should still work exactly the same with populating the db provided

### Actual behavior
Tell us what happens instead
Errors when I run `npm run migrate` or `npm run dev` (or start).

//error Error: You must provide a Model (the initialized knex object)



### System configuration

Tell us about the applicable parts of your setup.

**Module versions** (especially the part that's not working):
"mysql": "^2.18.1",
"@feathersjs/feathers": "^5.0.0",

**NodeJS version**:
v18.17.1

**Operating System**:
Windows

**Browser Version**:

**React Native Version**:

**Module Loader**: