Skip to content

Small and very useful mysql database table generator

Notifications You must be signed in to change notification settings

BahlulHasanli/Padar

Repository files navigation

Padar Db Table Builder

Small and very useful mysql database table generator

Getting started

npm i -g and npm i

How do I use it?

// connection.js

const { createPool } = require('mysql2');

const connection = createPool({
  host: 'localhost',
  user: process.env.DB_USER,
  password: process.env.DB_PASSWORD,
  database: process.env.DB_NAME,
});

module.exports = connection;
// schema.js

const types = require('../utils/types.js');

const { autoincrement, varchar, int, notnull } = types;

const schema = [
  {
    tableName: 'customers',
    primary_key: ['CUSTOMER', 'id, customerFullName'],
    exists: true,
    columns: [
      { row: 'id', type: autoincrement(), void: notnull() },
      { row: 'customerFullName', type: varchar(250) },
      { row: 'customerEmail', type: varchar(255), void: notnull() },
    ],
  },
  {
    tableName: 'users',
    exists: false,
    primary_key: ['USERS', 'id'],
    columns: [
      { row: 'id', type: autoincrement(), void: notnull() },
      { row: 'userFullName', type: varchar(250) },
      { row: 'userEmail', type: varchar(255), void: notnull() },
      { row: 'password', type: int(20), void: notnull() },
      { row: 'phone', type: int(20) },
    ],
  },
  {
    tableName: 'personals',
    exists: false,
    primary_key: ['PERSONALS', 'id'],
    columns: [
      { row: 'id', type: autoincrement(), void: notnull() },
      { row: 'personalName', type: varchar(100) },
      { row: 'personalEmail', type: varchar(150), void: notnull() },
      { row: 'password', type: int(10), void: notnull() },
      { row: 'phone', type: int(10) },
    ],
  },
];

module.exports = schema;

Then you just have to start Padar

padar create

About

Small and very useful mysql database table generator

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published