I ended up creating three teams when trying to configure Mattermost, and I’d like to remove two of them.
By the way, apparently you can’t have the word “web” in your team’s URL. I wanted it to be /weblinx/, the name of my company, but it just generated /linx/.
It is possible to manually manipulate the database to remove a team and I’ll show you how below. First though, a warning that any database manipulation is NOT recommended, especially if you have critical data you don’t want to lose.
That said if you’re using MySQL you can remove a team by doing the following:
Login to MySQL with mysql --host=dockerhost --user=mmuser --password=mostest
i. This might be mysql --host=localhost --user=mmuser --password=mostest if you’re running release bits.
Select the database with use mattermost_test;
i. The database name might also be mattermost or mattermost_production
Find the team Id with SELECT Id FROM Teams WHERE Name = 'someteamname'; and copy it
Delete the team with DELETE FROM Teams WHERE Id = 'yourteamid';
Delete the users with DELETE FROM Users WHERE TeamId = 'yourteamid';
Delete the sessions with DELETE FROM Sessions WHERE TeamId = 'yourteamid';
(Optional) Delete the channels with DELETE FROM Channels WHERE TeamId = 'yourteamid';
Restart your server to clear the sessions cache.
Doing this might have unintended side effects, so it’s up to you whether or not to do it. The steps for Postgres should be very similar.
Speaking of the command line tool, it wasn’t working for me last week… Details are in my Slack import failure thread, but can someone supply a working example command line to delete a team?
Update: for others who end up here looking for help, we resolved my problem in my other thread. TL;DR when the command line tool asks questions, respond with YES in all caps.
I read the cli docu linked above but its not working for me:
root@254daecba851:/mattermost/bin#sudo ./platform team delete AMS
Have you performed a database backup? (YES/NO):
YES
Are you sure you want to delete the teams specified? All data will be permanently deleted? (YES/NO):
YES
Unable to find team 'AMS'
root@254daecba851:/mattermost/bin#
I also tried sudo ./platform team delete “AMS” and its not working either, same error. I do see the team though in my System Console.
On mattermost when you go to team settings > General Settings > Team Name, try to copy the name exactly as is and use it, if there is spacing put it inside quotes, like " name here" and see if that works…
Additionally you could try pointing your config file on the command line like -c path_to_your/config.json
root@254daecba851:/mattermost/bin# ./platform team delete "AMS" -c /mattermost/config/config.json
Have you performed a database backup? (YES/NO):
YES
Are you sure you want to delete the teams specified? All data will be permanently deleted? (YES/NO):
YES
Unable to find team 'AMS'
root@254daecba851:/mattermost/bin#
I looked in the database for my instance of Mattermost 3.7.2 and noticed that the Team database holds two versions of the team name. One is the DisplayName, and the other is Name. I experimented a little and found that the command doesn’t work when you use DisplayName. You have to use Name.
The Name is created from the DisplayName by replacing spaces with dashes and converting to lowercase. So if your team name is AMS, then its name in the database is ams.