Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
M
matrix-appservice-discord
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Wiki externe
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneurs
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté GitLab
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
salixor
matrix-appservice-discord
Validations
bd5bc543
Valider
bd5bc543
rédigé
Il y a 6 ans
par
Will Hunt
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Test v8 migrations
parent
3fd2b98e
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
2
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
2 fichiers modifiés
src/db/schema/v8.ts
+9
-0
9 ajouts, 0 suppression
src/db/schema/v8.ts
test/db/test_roomstore.ts
+72
-0
72 ajouts, 0 suppression
test/db/test_roomstore.ts
avec
81 ajouts
et
0 suppression
src/db/schema/v8.ts
+
9
−
0
Voir le fichier @
bd5bc543
...
@@ -62,18 +62,27 @@ export class Schema implements IDbSchema {
...
@@ -62,18 +62,27 @@ export class Schema implements IDbSchema {
}
}
log
.
warn
(
"
Migrating rooms from roomstore, this may take a while...
"
);
log
.
warn
(
"
Migrating rooms from roomstore, this may take a while...
"
);
const
rooms
=
await
this
.
roomStore
.
select
({});
const
rooms
=
await
this
.
roomStore
.
select
({});
log
.
info
(
`Found
${
rooms
.
length
}
rooms in the DB`
);
// Matrix room only entrys are useless.
// Matrix room only entrys are useless.
const
entrys
=
rooms
.
filter
((
r
)
=>
r
.
remote
);
const
entrys
=
rooms
.
filter
((
r
)
=>
r
.
remote
);
log
.
info
(
`Filtered out rooms without remotes. Have
${
entrys
.
length
}
entries`
);
let
migrated
=
0
;
for
(
const
e
of
entrys
)
{
for
(
const
e
of
entrys
)
{
const
matrix
=
new
MatrixStoreRoom
(
e
.
matrix_id
);
const
matrix
=
new
MatrixStoreRoom
(
e
.
matrix_id
);
try
{
try
{
const
remote
=
new
RemoteStoreRoom
(
e
.
remote_id
,
e
.
remote
);
const
remote
=
new
RemoteStoreRoom
(
e
.
remote_id
,
e
.
remote
);
await
store
.
roomStore
.
linkRooms
(
matrix
,
remote
);
await
store
.
roomStore
.
linkRooms
(
matrix
,
remote
);
log
.
info
(
`Migrated
${
matrix
.
roomId
}
`
);
log
.
info
(
`Migrated
${
matrix
.
roomId
}
`
);
migrated
++
;
}
catch
(
ex
)
{
}
catch
(
ex
)
{
log
.
error
(
`Failed to link
${
matrix
.
roomId
}
: `
,
ex
);
log
.
error
(
`Failed to link
${
matrix
.
roomId
}
: `
,
ex
);
}
}
}
}
if
(
migrated
!==
entrys
.
length
)
{
log
.
error
(
`Didn't migrate all rooms,
${
entrys
.
length
-
migrated
}
failed to be migrated.`
);
}
else
{
log
.
info
(
"
Migrated all rooms successfully
"
);
}
}
}
public
async
rollBack
(
store
:
DiscordStore
):
Promise
<
void
>
{
public
async
rollBack
(
store
:
DiscordStore
):
Promise
<
void
>
{
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
test/db/test_roomstore.ts
+
72
−
0
Voir le fichier @
bd5bc543
...
@@ -193,3 +193,75 @@ describe("RoomStore", () => {
...
@@ -193,3 +193,75 @@ describe("RoomStore", () => {
});
});
});
});
});
});
describe
(
"
RoomStore.schema.v8
"
,
()
=>
{
it
(
"
will successfully migrate rooms
"
,
async
()
=>
{
const
SCHEMA_VERSION
=
8
;
store
=
new
DiscordStore
(
"
:memory:
"
);
const
roomStore
=
{
select
:
()
=>
{
return
[
{
_id
:
"
DGFUYs4hlXNDmmw0
"
,
id
:
"
123
"
,
matrix
:
{
extras
:
{}},
matrix_id
:
"
!badroom:localhost
"
,
},
{
_id
:
"
Dd37MWDw57dAQz5p
"
,
data
:
{},
id
:
"
!xdnLTCNErGnwsGnmnm:localhost discord_282616294245662720_514843269599985674_bridged
"
,
matrix
:
{
extras
:
{},
},
matrix_id
:
"
!bridged1:localhost
"
,
remote
:
{
discord_channel
:
"
514843269599985674
"
,
discord_guild
:
"
282616294245662720
"
,
discord_type
:
"
text
"
,
plumbed
:
false
,
},
remote_id
:
"
discord_282616294245662720_514843269599985674_bridged
"
,
},
{
_id
:
"
H3XEftQWj8BZYuCe
"
,
data
:
{},
id
:
"
!oGkfjmeNEkJdFasVRF:localhost discord_282616294245662720_520332167952334849
"
,
matrix
:
{
extras
:
{},
},
matrix_id
:
"
!bridged2:localhost
"
,
remote
:
{
discord_channel
:
"
514843269599985674
"
,
discord_guild
:
"
282616294245662720
"
,
discord_type
:
"
text
"
,
plumbed
:
true
,
update_icon
:
true
,
update_name
:
false
,
update_topic
:
true
,
},
remote_id
:
"
discord_282616294245662720_520332167952334849
"
,
},
];
},
};
await
store
.
init
(
SCHEMA_VERSION
,
roomStore
);
expect
(
await
store
.
roomStore
.
getEntriesByMatrixId
(
"
!badroom:localhost
"
)).
to
.
be
.
empty
;
const
bridge1
=
(
await
store
.
roomStore
.
getEntriesByMatrixId
(
"
!bridged1:localhost
"
))[
0
];
expect
(
bridge1
).
to
.
exist
;
expect
(
bridge1
.
remote
).
to
.
not
.
be
.
null
;
expect
(
bridge1
.
remote
!
.
data
.
discord_channel
).
to
.
be
.
equal
(
"
514843269599985674
"
);
expect
(
bridge1
.
remote
!
.
data
.
discord_guild
).
to
.
be
.
equal
(
"
282616294245662720
"
);
expect
(
bridge1
.
remote
!
.
data
.
discord_type
).
to
.
be
.
equal
(
"
text
"
);
expect
(
!!
bridge1
.
remote
!
.
data
.
plumbed
).
to
.
be
.
false
;
const
bridge2
=
(
await
store
.
roomStore
.
getEntriesByMatrixId
(
"
!bridged2:localhost
"
))[
0
];
expect
(
bridge2
).
to
.
exist
;
expect
(
bridge2
.
remote
).
to
.
not
.
be
.
null
;
expect
(
bridge2
.
remote
!
.
data
.
discord_channel
).
to
.
be
.
equal
(
"
514843269599985674
"
);
expect
(
bridge2
.
remote
!
.
data
.
discord_guild
).
to
.
be
.
equal
(
"
282616294245662720
"
);
expect
(
bridge2
.
remote
!
.
data
.
discord_type
).
to
.
be
.
equal
(
"
text
"
);
expect
(
!!
bridge2
.
remote
!
.
data
.
plumbed
).
to
.
be
.
true
;
expect
(
!!
bridge2
.
remote
!
.
data
.
update_icon
).
to
.
be
.
true
;
expect
(
!!
bridge2
.
remote
!
.
data
.
update_name
).
to
.
be
.
false
;
expect
(
!!
bridge2
.
remote
!
.
data
.
update_topic
).
to
.
be
.
true
;
});
});
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter