Instead to implement own logic how the database scheme should be updated or migrated to a newer or older version flucky use now instead the go-migrate package.
		
			
				
	
	
		
			10 lines
		
	
	
		
			704 B
		
	
	
	
		
			SQL
		
	
	
	
	
	
			
		
		
	
	
			10 lines
		
	
	
		
			704 B
		
	
	
	
		
			SQL
		
	
	
	
	
	
| CREATE TABLE temperatures (
 | |
|   id                      CHAR(36)                                                  NOT NULL,
 | |
|   value                   NUMERIC(10,3)                                             NOT NULL,
 | |
|   date                    TIMESTAMP                                                 NOT NULL,
 | |
|   sensor_id               CHAR(36)                                                  NOT NULL,
 | |
|   creation_date           TIMESTAMP       DEFAULT (datetime('now', 'localtime'))    NOT NULL,
 | |
|   update_date             TIMESTAMP,
 | |
|   CONSTRAINT pk_temperatures PRIMARY KEY(id),
 | |
|   CONSTRAINT fk_temperatures_id FOREIGN KEY(sensor_id) REFERENCES sensors(sensor_id) ON DELETE CASCADE ON UPDATE CASCADE
 | |
| ); |