old_contents: def up(config, conn, semester, course):
      with conn.cursor() as cursor:
          cursor.execute("ALTER TABLE ONLY users ADD COLUMN IF NOT EXISTS user_preferred_lastname character varying;")
  
  
  def down(config, conn, semester, course):
      with conn.cursor() as cursor:
          cursor.execute("ALTER TABLE ONLY users DROP COLUMN IF EXISTS user_preferred_lastname RESTRICT;")
  
new_contents: def up(config, conn, semester, course):
      with conn.cursor() as cursor:
          cursor.execute("SELECT * FROM users LIMIT 0")
          colnames = [desc[0] for desc in cursor.description]
          if 'user_preferred_lastname' not in colnames:
              cursor.execute('ALTER TABLE users ADD COLUMN user_preferred_lastname character varyings')
  
  def down(config, conn, semester, course):
      pass
  
subject: fix preferred lastname migration (#3046)