2 from migration_state
import _execute
, _execute_in_transaction
, table_present
4 MIGRATION_LOG_SQL
= """
5 CREATE TABLE `dmigrations_log` (
6 `id` int(11) NOT NULL auto_increment,
7 `action` VARCHAR(255) NOT NULL,
8 `migration` VARCHAR(255) NOT NULL,
9 `status` VARCHAR(255) NOT NULL,
10 `datetime` DATETIME NOT NULL,
12 ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8
17 Create migration log if it doesn't exist
19 if not table_present('dmigrations_log'):
20 _execute(MIGRATION_LOG_SQL
)
23 return list(_execute("""
24 SELECT action, migration, status, datetime
26 ORDER BY datetime, id"""
29 def log_action(action
, migration
, status
, when
=None):
31 when
= datetime
.datetime
.now()
32 _execute_in_transaction("""
33 INSERT INTO dmigrations_log(action, migration, status, datetime)
34 VALUES (%s, %s, %s, %s)
35 """, [action
, migration
, status
, when
])