Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Wolfgang Knopki
Spacedeck-open-SAML
Commits
f71081b1
Commit
f71081b1
authored
Jul 16, 2018
by
Alejandro Alonso
Browse files
Adding migration support and delete cascade migration for space references
parent
c075c562
Changes
3
Show whitespace changes
Inline
Side-by-side
models/db.js
View file @
f71081b1
//'use strict';
var
Umzug
=
require
(
'
umzug
'
);
//var mongoose = require('mongoose');
//const sqlite3 = require('sqlite3').verbose();
...
...
@@ -199,7 +200,7 @@ module.exports = {
updated_at
:
{
type
:
Sequelize
.
DATE
,
defaultValue
:
Sequelize
.
NOW
}
}),
init
:
function
()
{
init
:
async
function
()
{
User
=
this
.
User
;
Session
=
this
.
Session
;
Space
=
this
.
Space
;
...
...
@@ -256,7 +257,27 @@ module.exports = {
as
:
'
space
'
});
sequelize
.
sync
();
await
sequelize
.
sync
();
var
umzug
=
new
Umzug
({
storage
:
'
sequelize
'
,
storageOptions
:
{
sequelize
:
sequelize
},
migrations
:
{
params
:
[
sequelize
.
getQueryInterface
(),
Sequelize
],
path
:
'
./models/migrations
'
,
pattern
:
/
\.
js$/
}
});
umzug
.
up
().
then
(
function
(
migrations
)
{
console
.
log
(
'
Migration complete up!
'
);
});
},
getUserRoleInSpace
:
(
originalSpace
,
user
,
cb
)
=>
{
...
...
models/migrations/01-spaces-delete-cascade.js
0 → 100644
View file @
f71081b1
'
use strict
'
;
module
.
exports
=
{
up
:
function
(
migration
,
DataTypes
)
{
return
[
migration
.
changeColumn
(
'
memberships
'
,
'
space_id
'
,
{
type
:
DataTypes
.
STRING
,
references
:
{
model
:
'
spaces
'
,
key
:
'
_id
'
},
onDelete
:
'
CASCADE
'
,
onUpdate
:
'
CASCADE
'
}
),
migration
.
changeColumn
(
'
artifacts
'
,
'
space_id
'
,
{
type
:
DataTypes
.
STRING
,
references
:
{
model
:
'
spaces
'
,
key
:
'
_id
'
},
onDelete
:
'
CASCADE
'
,
onUpdate
:
'
CASCADE
'
}
),
migration
.
changeColumn
(
'
messages
'
,
'
space_id
'
,
{
type
:
DataTypes
.
STRING
,
references
:
{
model
:
'
spaces
'
,
key
:
'
_id
'
},
onDelete
:
'
CASCADE
'
,
onUpdate
:
'
CASCADE
'
}
)
]
},
down
:
function
(
migration
,
DataTypes
)
{
return
[
migration
.
changeColumn
(
'
memberships
'
,
'
space_id
'
,
{
type
:
DataTypes
.
STRING
,
references
:
{
model
:
'
spaces
'
,
key
:
'
_id
'
},
onDelete
:
'
CASCADE
'
,
onUpdate
:
'
NO ACTION
'
}
),
,
migration
.
changeColumn
(
'
artifacts
'
,
'
space_id
'
,
{
type
:
DataTypes
.
STRING
,
references
:
{
model
:
'
spaces
'
,
key
:
'
_id
'
},
onDelete
:
'
CASCADE
'
,
onUpdate
:
'
NO ACTION
'
}
),
migration
.
changeColumn
(
'
messages
'
,
'
space_id
'
,
{
type
:
DataTypes
.
STRING
,
references
:
{
model
:
'
spaces
'
,
key
:
'
_id
'
},
onDelete
:
'
CASCADE
'
,
onUpdate
:
'
NO ACTION
'
}
)
]
}
};
package.json
View file @
f71081b1
...
...
@@ -40,6 +40,7 @@
"
slug
"
:
"
0.9.1
"
,
"
sqlite3
"
:
"
^4.0.0
"
,
"
swig
"
:
"
1.4.2
"
,
"
umzug
"
:
"
^2.1.0
"
,
"
underscore
"
:
"
1.8.3
"
,
"
uuid
"
:
"
^3.2.1
"
,
"
validator
"
:
"
7.0.0
"
,
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment