m0001_create_users_table.php 851 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. use App\Core\Application;
  3. /*
  4. * Migración que crea la tabla de usuarios.
  5. */
  6. class m0001_create_users_table
  7. {
  8. public function up()
  9. {
  10. $db = Application::$app->db;
  11. $query = 'CREATE TABLE IF NOT EXISTS users (
  12. id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  13. firstname VARCHAR(255) NOT NULL,
  14. lastname VARCHAR(255) NOT NULL,
  15. email VARCHAR(255) NOT NULL,
  16. password VARCHAR(255) NOT NULL,
  17. status TINYINT UNSIGNED NOT NULL,
  18. created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  19. CONSTRAINT users_id_primary PRIMARY KEY(id)
  20. );';
  21. $db->pdo->exec($query);
  22. }
  23. public function down()
  24. {
  25. $db = Application::$app->db;
  26. $query = 'DROP TABLE IF EXISTS users';
  27. $db->pdo->exec($query);
  28. }
  29. }