@aceitadev/adatabase 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/SchemaManager.js +13 -1
- package/package.json +1 -1
package/dist/SchemaManager.js
CHANGED
|
@@ -139,7 +139,19 @@ ${col}
|
|
|
139
139
|
if (type === String && opts && opts.limit) {
|
|
140
140
|
sqlType = `VARCHAR(${opts.limit})`;
|
|
141
141
|
}
|
|
142
|
-
|
|
142
|
+
const isNullable = nullableMeta === null || nullableMeta === void 0 ? void 0 : nullableMeta.get(prop);
|
|
143
|
+
sqlType += isNullable ? " NULL" : " NOT NULL";
|
|
144
|
+
if (type === Date && !isNullable) {
|
|
145
|
+
if (adapter.type === 'mysql') {
|
|
146
|
+
sqlType += " DEFAULT CURRENT_TIMESTAMP";
|
|
147
|
+
if (colName === 'updated_at') {
|
|
148
|
+
sqlType += " ON UPDATE CURRENT_TIMESTAMP";
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
else if (adapter.type === 'postgres') {
|
|
152
|
+
sqlType += " DEFAULT CURRENT_TIMESTAMP";
|
|
153
|
+
}
|
|
154
|
+
}
|
|
143
155
|
if (opts && opts.unique)
|
|
144
156
|
sqlType += " UNIQUE";
|
|
145
157
|
columns[colName] = sqlType;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aceitadev/adatabase",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Uma biblioteca para facilitar a interação com bancos de dados MySQL e PostgreSQL em projetos TypeScript/Node.js.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|