From 7274f78456c0b99873f6d90be6822418113b1a26 Mon Sep 17 00:00:00 2001 From: MockTech <83368864+MockTech@users.noreply.github.com> Date: Mon, 18 Jul 2022 16:15:41 -0400 Subject: [PATCH] Readme 80% Revert to dev version Co-authored-by: Angel Giron --- README.md | 52 +++++++++------- server/controllers/dataController.js | 92 ++++++++++++++-------------- 2 files changed, 75 insertions(+), 69 deletions(-) diff --git a/README.md b/README.md index 17620cf6..092e5842 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@
- ![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square) ![Version](https://img.shields.io/badge/version-1.0.1-blue) ![GitHub Stars](https://img.shields.io/github/stars/oslabs-beta/JAKT?color=%23fb7182) @@ -14,7 +13,6 @@

Visualize and Modify your database with dbSpy!

dbSpy is an open-source database visualization tool to facilitate relational database model development using entity relationship diagrams and homogeneous database migration.

-

### Use Cases
Connecting to an existing database @@ -46,42 +44,50 @@ Provides a canvas for users to create a database by using ER diagrams, thus crea 6. **Query Generator:** Generate an executable SQL query with every modification to your schema -7. **Screeshot:** Take a screenshot of the canvas (BETA) +7. **Screenshot:** Take a screenshot of the canvas with all your tables (BETA) 7. **Time Travel:** Provides a history of edits for easier backtracking ### How to Use -1. Instructions on how to connect to DB -2. Instructions on how to upload sql file +Connecting to an existing database +1. Locate the Feature bar on the left side of the page and click on "Connect database". This will open a sidebar on the right side of the page. +2. Input the database information to your Postgres database and click on "Connect". It may take a couple of seconds to connect to your database. +3. Once the connection to your database is established, you will see the page populate with the tables in your database and the relationships between your tables. +4. You will then be able to make changes to the schema of your database. Updated the field names, the values, +2. Instructions on how to upload sql file. 3. Instructions on how to start design from scratch ### How to contribute -The following is a list of features and improvements for which you can contribute. If you have any additional ideas, please raise the issue or implement them as well! -- Screenshot feature - The screenshot feature does presently does not capture the tables with the arrows. -- SQL file export feature - After a user creates a database from scratch on dbSpy, this feature would create a list of executable queries for them to actually create that database. -- Save feature - Saves queries made into a SQL file and allowing user to execute queries on their own. -- query box when design from scratch +Below is a list of features and improvements to which you can contribute. If you have any additional ideas, please raise the issue or implement them as well! +- Screenshot feature - The screenshot feature does presently does not capture the tables with the arrows. It would be best if the features captures everything as it is rendered on the canvas. +- SQL File Export feature (for new databases) - After a user creates a database from scratch on dbSpy, this feature would create a SQL file with a list of executable queries for them to create that new database on their own. +- SQL File Export feature (for existing databases) - After a user makes changes to their databases's schema, this feature would create a SQL file with a list of executable queries for them to execute those changes on their existing database. --- -### If you'd like to contribute to our project -- Fork the project +### Getting started +- Fork and clone this repo +- Install the dependencies: ```bash $ npm install ``` -- Run the project in development mode: $ npm run dev +- Run the project in development mode: +```bash +$ npm run dev +``` - Make changes with comments -- Add appropriate tests and make sure they pass -- Commit and PR +- Add appropriate tests and ensure they pass +- Commit your changes and make a pull request + +### Request a feature +- Submit an appropriately tagged GitHub issue +- Submit your request here ### Credits/Contributors -- Contributor • [LinkedIn](link) • [Github](link) -- Contributor • [LinkedIn](link) • [Github](link) -- Contributor • [LinkedIn](link) • [Github](link) -- Contributor • [LinkedIn](link) • [Github](link) +- Angel Giron • [LinkedIn](https://www.linkedin.com/in/acgiron/) • [Github](https://github.com/g94angel) +- John Paul Adigwu • [LinkedIn](https://www.linkedin.com/in/johnpaul-adigwu/) • [Github](https://github.com/engineerous) +- Kevin Park-Lee • [LinkedIn](https://www.linkedin.com/in/kevin38424/) • [Github](https://github.com/kevin38424) +- Tarik Mokhtech • [LinkedIn](http://linkedin.com/in/tarik-mokhtech) • [Github](https://github.com/MockTech) ### License -- dbSpy is developed under the MIT license. - -### How to request a feature -- Submit an appropriately tagged github issue \ No newline at end of file +- dbSpy is developed under the MIT license. \ No newline at end of file diff --git a/server/controllers/dataController.js b/server/controllers/dataController.js index 3f341b17..24e52ee3 100644 --- a/server/controllers/dataController.js +++ b/server/controllers/dataController.js @@ -118,54 +118,54 @@ dataController.testDrop = (req, res, next) => { * Option2 - Dev: Use .sql file provided in db_schema and parse, pass parsed data to next middleware. */ dataController.getSchema = (req, res, next) => { - // Option 1 - Production - let result = null; - console.log("running getSchema controller..."); - const hostname = req.body.hostname; - const password = req.body.password; - const port = req.body.port; - const username = req.body.username; - const database_name = req.body.database_name; - const command = postgresDumpQuery(hostname,password,port, username, database_name); - console.log(command, '<-command'); - writeSchema(command).then(resq => { - fs.readFile(command[1], 'utf8', (error, data) => { - if (error) - { - console.error(`error- in FS: ${error.message}`); - return next({ - msg: 'Error reading database schema file', - err: error}); - } - result = parseSql(data); - res.locals.data = result; - next(); - }); - }); - }; + // // Option 1 - Production + // let result = null; + // console.log("running getSchema controller..."); + // const hostname = req.body.hostname; + // const password = req.body.password; + // const port = req.body.port; + // const username = req.body.username; + // const database_name = req.body.database_name; + // const command = postgresDumpQuery(hostname,password,port, username, database_name); + // console.log(command, '<-command'); + // writeSchema(command).then(resq => { + // fs.readFile(command[1], 'utf8', (error, data) => { + // if (error) + // { + // console.error(`error- in FS: ${error.message}`); + // return next({ + // msg: 'Error reading database schema file', + // err: error}); + // } + // result = parseSql(data); + // res.locals.data = result; + // next(); + // }); + // }); + // }; -// // Option 2 - Dev -// fs.readFile( -// path.join(__dirname, '../db_schemas/twvoyfdatwvoyfda1656566683.sql'), -// 'utf8', -// (error, data) => { -// if (error) { -// console.error(`error- in FS: ${error.message}`); -// return next({ -// msg: 'Error reading database schema file', -// err: error, -// }); -// } -// const result = parseSql(data); -// //console.log(result); -// //console.log('instance of table', result[records]); -// console.log('result--->', result) -// res.locals.data = result; // Is this for loop necessary? -- NOTE -// next(); -// } -// ); -// }; + // Option 2 - Dev + fs.readFile( + path.join(__dirname, '../db_schemas/swd.sql'), + 'utf8', + (error, data) => { + if (error) { + console.error(`error- in FS: ${error.message}`); + return next({ + msg: 'Error reading database schema file', + err: error, + }); + } + const result = parseSql(data); + //console.log(result); + //console.log('instance of table', result[records]); + console.log('result--->', result) + res.locals.data = result; // Is this for loop necessary? -- NOTE + next(); + } + ); +}; // // Option 2 - Dev // fs.readFile(