Installations
npm install @fxjs/sql-ddl-sync
Developer Guide
Typescript
Yes
Module System
CommonJS
Node Version
18.18.2
NPM Version
lerna/8.1.2/node@v18.18.2+x64 (win32)
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (56.96%)
TypeScript (43.04%)
Developer
Download Statistics
Total Downloads
41,673
Last Day
4
Last Week
24
Last Month
128
Last Year
2,109
GitHub Statistics
3 Stars
567 Commits
5 Forks
7 Watching
17 Branches
7 Contributors
Bundle Size
54.76 kB
Minified
11.65 kB
Minified + Gzipped
Package Meta Information
Latest Version
0.11.6
Package Id
@fxjs/sql-ddl-sync@0.11.6
Unpacked Size
106.89 kB
Size
17.78 kB
File Count
29
NPM Version
lerna/8.1.2/node@v18.18.2+x64 (win32)
Node Version
18.18.2
Publised On
16 May 2024
Total Downloads
Cumulative downloads
Total Downloads
41,673
Last day
100%
4
Compared to previous day
Last week
71.4%
24
Compared to previous week
Last month
184.4%
128
Compared to previous month
Last year
-50.4%
2,109
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
3
Peer Dependencies
2
Fibjs SQL DDL Synchronization
NOTICE: This is node-sql-ddl-sync's fibjs version, thx a lot to node-sql-ddl-sync's author : )
Install
1npm install @fxjs/sql-ddl-sync
Dialects
- MySQL
- SQLite
About
Originally, this module is part of @fxjs/orm. It's used synchronize model tables in supported dialects.
But now, it could run without @fxjs/orm, just install @fxjs/db-driver instead 🚀 Sorry there is no API documentation for now but there are a couple of tests you can read and find out how to use it if you want.
Version Match
sql-ddl-sync Version | required orm Version |
---|---|
sql-ddl-sync <= 0.3.x | orm < 1.10.3 |
sql-ddl-sync = 0.4.x | orm >= 1.10.3 |
sql-ddl-sync >= 0.5.x | don't need! |
Example
Install @fxjs/db-driver. Create a file with the contents below and change insert your database credentials.
Run once and you'll see table ddl_sync_test
appear in your database. Then make some changes to it (add/drop/change columns)
and run the code again. Your table should always return to the same structure.
1const DBDriver = require("@fxjs/db-driver"); 2const mysql = require("mysql"); 3const Sync = require("@fxjs/sql-ddl-sync").Sync; 4 5const dbdriver = DBDriver.create("mysql://username:password@localhost/database"); 6 7const sync = new Sync({ 8 dbdriver: dbdriver, 9 debug : function (text) { 10 console.log("> %s", text); 11 } 12}); 13 14sync.defineCollection("ddl_sync_test", { 15 id : { type: "serial", key: true, serial: true }, 16 name : { type: "text", required: true }, 17 age : { type: "integer" }, 18 male : { type: "boolean" }, 19 born : { type: "date", time: true }, 20 born2 : { type: "date" }, 21 int2 : { type: "integer", size: 2 }, 22 int4 : { type: "integer", size: 4 }, 23 int8 : { type: "integer", size: 8 }, 24 float4 : { type: "number", size: 4 }, 25 float8 : { type: "number", size: 8 }, 26 photo : { type: "binary" } 27}); 28 29try { 30 sync.sync() 31 console.log("> Sync Done"); 32} catch (err) { 33 if (err) { 34 console.log("> Sync Error"); 35 console.log(err); 36 } 37} 38 39process.exit(0);
Test
To test, first make sure you have development dependencies installed. Go to the root folder and do:
1npm install
Then, just run the tests.
1npm test
If you have a supported database server and want to test against it, first install the module:
And then run:
1URI=mysql://username:password@localhost/database fibjs test/run-db
Credits
This repo is checked out from Diogo Resende's node-sql-ddl-sync, which is one part of orm
, and orm is the original source of @fxjs/orm
. Thx a lot to him and his partner.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: License:0
- Info: FSF or OSI recognized license: MIT License: License:0
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/deploy.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/fxjs-modules/orm/deploy.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/deploy.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/fxjs-modules/orm/deploy.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/deploy.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/fxjs-modules/orm/deploy.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/run-ci.yml:38: update your workflow using https://app.stepsecurity.io/secureworkflow/fxjs-modules/orm/run-ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/run-ci.yml:42: update your workflow using https://app.stepsecurity.io/secureworkflow/fxjs-modules/orm/run-ci.yml/master?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/run-ci.sh:23
- Warn: npmCommand not pinned by hash: .github/workflows/deploy.yml:21
- Warn: npmCommand not pinned by hash: .github/workflows/run-ci.yml:81
- Info: 0 out of 4 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 third-party GitHubAction dependencies pinned
- Info: 2 out of 5 npmCommand dependencies pinned
Reason
Found 4/30 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/deploy.yml:1
- Warn: no topLevel permission defined: .github/workflows/run-ci.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 6 are checked with a SAST tool
Score
4.1
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More