Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
blendb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pdts20
blendb
Commits
4dd84cad
Commit
4dd84cad
authored
Feb 7, 2018
by
Lucas Fernandes de Oliveira
Browse files
Options
Downloads
Patches
Plain Diff
Issue#59: Fix createSchema.ts and add npm run schema
Signed-off-by:
Lucas Fernandes de Oliveira
<
lfo14@inf.ufpr.br
>
parent
d7beb242
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
package.json
+1
-1
1 addition, 1 deletion
package.json
scripts/schema.ts
+35
-4
35 additions, 4 deletions
scripts/schema.ts
src/util/configParser.ts
+5
-2
5 additions, 2 deletions
src/util/configParser.ts
with
42 additions
and
7 deletions
.gitignore
+
1
−
0
View file @
4dd84cad
...
...
@@ -19,3 +19,4 @@
/dist
/database/views
/service
schema.sql
This diff is collapsed.
Click to expand it.
package.json
+
1
−
1
View file @
4dd84cad
...
...
@@ -9,7 +9,7 @@
"test"
:
"env $(cat config/test.env) ts-node node_modules/istanbul/lib/cli.js cover -x
\"
**/*.spec.ts
\"
-e .ts _mocha"
,
"show-coverage"
:
"xdg-open coverage/lcov-report/index.html"
,
"doc-api"
:
"raml2html -i specs/blendb-api-v1.raml -o doc/api-v1-reference.html"
,
"
database"
:
"ts-node database/config.ts database
"
,
"
schema"
:
"env $(cat config/config.env ) ts-node scripts/schema.ts config/config.yaml schema.sql
"
,
"service"
:
"./scripts/service.sh"
},
"repository"
:
{
...
...
This diff is collapsed.
Click to expand it.
database/createS
chema.ts
→
scripts/s
chema.ts
+
35
−
4
View file @
4dd84cad
...
...
@@ -52,8 +52,20 @@ for (let i = 0; i < config.buildViews.length; ++i) {
if
(
view
.
origin
)
{
// Cria uma tabela
let
output
=
"
-- View:
"
+
alias
+
"
\n
"
;
if
(
process
.
env
.
BLENDB_ADAPTER
===
"
postgres
"
)
{
output
+=
"
DROP VIEW IF EXISTS view_
"
+
view
.
id
+
"
CASCADE;
\n
"
;
output
+=
"
CREATE OR REPLACE VIEW view_
"
+
view
.
id
+
"
AS
\n
"
;
}
else
if
(
process
.
env
.
BLENDB_ADAPTER
===
"
monet
"
)
{
output
+=
"
DROP VIEW view_
"
+
view
.
id
+
"
CASCADE;
\n
"
;
output
+=
"
CREATE VIEW view_
"
+
view
.
id
+
"
AS
\n
"
;
}
else
{
console
.
log
(
"
The adapter value:
"
,
process
.
env
.
BLENDB_ADAPTER
,
"
is invalid. Abort
"
);
process
.
exit
(
1
);
}
output
+=
fs
.
readFileSync
(
referencePath
+
"
/
"
+
filePath
,
{
encoding
:
"
utf-8
"
});
schema
+=
output
+
"
\n
"
;
engine
.
addView
(
view
);
...
...
@@ -72,10 +84,25 @@ for (let i = 0; i < config.buildViews.length; ++i) {
});
const
table
=
adapter
.
getQueryFromView
(
materializedView
);
const
query
=
"
-- View:
"
+
alias
+
"
\n
"
+
"
DROP MATERIALIZED VIEW IF EXISTS view_
"
+
view
.
id
+
"
CASCADE;
\n
"
+
let
query
=
"
-- View:
"
+
alias
+
"
\n
"
;
if
(
process
.
env
.
BLENDB_ADAPTER
===
"
postgres
"
)
{
query
+=
"
DROP MATERIALIZED VIEW IF EXISTS view_
"
+
view
.
id
+
"
CASCADE;
\n
"
+
"
CREATE MATERIALIZED VIEW view_
"
+
materializedView
.
id
+
"
AS
"
+
table
+
"
\n\n
"
;
}
else
if
(
process
.
env
.
BLENDB_ADAPTER
===
"
monet
"
)
{
console
.
log
(
"
MonetDb does not support Materializaed views. Abort
"
);
console
.
log
(
"
All views in config.yaml must be origin form MonetDB
"
);
console
.
log
(
"
This is a known issue.
"
);
console
.
log
(
"
In the future this script will create a table and copy the data.
"
);
process
.
exit
(
1
);
}
else
{
console
.
log
(
"
The adapter value:
"
,
process
.
env
.
BLENDB_ADAPTER
,
"
is invalid. Abort
"
);
process
.
exit
(
1
);
}
schema
+=
query
;
engine
.
addView
(
materializedView
);
...
...
@@ -88,4 +115,8 @@ fs.writeFile(schemaFile, schema, (error) => {
process
.
exitCode
=
1
;
return
;
}
else
{
console
.
log
(
"
File:
"
+
schemaFile
+
"
created
"
);
}
});
This diff is collapsed.
Click to expand it.
src/util/configParser.ts
+
5
−
2
View file @
4dd84cad
...
...
@@ -96,9 +96,12 @@ export class ConfigParser {
port
:
parseInt
(
process
.
env
.
BLENDB_DB_PORT
,
10
)
};
const
strCreate
=
process
.
env
.
BLENDB_ST_CREATE
;
const
strInsert
=
process
.
env
.
BLENDB_ST_INSERT
;
let
struct
:
LoadStruct
=
{
create
:
process
.
env
.
BLENDB_ST_CREATE
.
toLowerCase
()
===
"
true
"
,
insert
:
process
.
env
.
BLENDB_ST_INSERT
.
toLowerCase
()
===
"
true
"
create
:
(
strCreate
)
?
strCreate
.
toLowerCase
()
===
"
true
"
:
false
,
insert
:
(
strInsert
)
?
strInsert
.
toLowerCase
()
===
"
true
"
:
false
};
let
metricsOpts
=
config
.
metrics
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment