欧洲中部时间10月17日晚上10点45分左右,Keepthescore的创始人兼程序员在几杯红酒下肚后,无意中删除了生产数据库。超过300.00个记分牌及相关数据顿时人间蒸发。

有人忍不住会将这场灾难归咎于几杯红酒。然而,擦除数据库的函数却是在清醒的时候编写的。一个函数删除了本地数据库,并从头开始创建所有必需的表。今天晚上,就在深夜编写一些代码之际,该函数连接到生产数据库,并清除了该数据库。
为什么?目前仍在努力搞明白原因。
以下是造成灾难的代码:
def database_model_create():"""Only works on localhost to prevent catastrophe"""database = config.DevelopmentConfig.DB_DATABASEuser = config.DevelopmentConfig.DB_USERNAMEpassword = config.DevelopmentConfig.DB_PASSWORDport = config.DevelopmentConfig.DB_PORTlocal_db = PostgresqlDatabase(database=database, user=user, password=password, host='localhost', port=port)local_db.drop_tables([Game, Player, Round, Score, Order])local_db.create_tables([Game, Player, Round, Score, Order])print('Initialized the local database.')
请注意,host被硬编码成了localhost。这意味着它永远无法连接到除开发者机器之外的任何机器上。另外:当然,Keepthescore为开发和生产环境使用不同的密码和用户。眼下他们太累了,还没有搞清是怎么回事。

相关阅读:
微盟“删库”主角贺某被判 6 年有期徒刑:酒后生活不如意、无力偿还网贷等个人原因“删库”





