 
 	, xz_final_img		BYTEA
 	, yz_final_img		BYTEA
-) INHERITS (fs_param);
+);
 
 CREATE TABLE others (
 	  name		TEXT	NOT NULL	PRIMARY KEY
 	, cfg		JSON	NOT NULL
 );
+
+CREATE OR REPLACE FUNCTION back_up() RETURNS TRIGGER AS $$
+	DECLARE max_history_version INTEGER;
+	BEGIN
+	IF TG_OP = 'UPDATE' THEN
+		INSERT INTO fs_param_history SELECT OLD.*;
+		NEW.bts = CURRENT_TIMESTAMP;
+		NEW.version = OLD.version + 1;
+		RETURN NEW;
+	ELSIF TG_OP = 'INSERT' THEN
+		SELECT MAX(version) INTO max_history_version FROM fs_param_history WHERE seqn = NEW.seqn;
+		IF max_history_version IS NULL THEN
+			NEW.bts = CURRENT_TIMESTAMP;
+			RETURN NEW;
+		ELSE
+			NEW.bts = CURRENT_TIMESTAMP;
+			NEW.version = max_history_version + 2;
+			RETURN NEW;
+		END IF;
+	ELSIF TG_OP = 'DELETE' THEN
+		INSERT INTO fs_param_history SELECT OLD.*;
+		RETURN OLD;
+	END IF;
+	END;
+	$$ LANGUAGE plpgsql;
+
+CREATE TRIGGER update_backup BEFORE UPDATE OR DELETE OR INSERT
+	ON fs_param FOR EACH ROW
+	EXECUTE PROCEDURE back_up();

	, defect_yzr_hangle	DT_ANGLE	NOT NULL
	, defect_yzr_vangle	DT_ANGLE	NOT NULL
	, defect_yzr_clad_dm	DT_LENGTH	NOT NULL
	, defect_yzl_core_dm	DT_LENGTH	NOT NULL

	, defect_xzl_dbmp	INT4		NOT NULL
	, defect_xzl_hangle	DT_ANGLE	NOT NULL
	, defect_xzl_vangle	DT_ANGLE	NOT NULL
	, defect_xzl_clad_dm	DT_LENGTH	NOT NULL
	, defect_yzl_core_dm	DT_LENGTH	NOT NULL

	, defect_xzr_dbmp	INT4		NOT NULL
	, defect_xzr_hangle	DT_ANGLE	NOT NULL
	, defect_xzr_vangle	DT_ANGLE	NOT NULL
	, defect_xzr_clad_dm	DT_LENGTH	NOT NULL
	, defect_yzl_core_dm	DT_LENGTH	NOT NULL

	, defect_yz_hangle	DT_ANGLE	NOT NULL
	, defect_xz_hangle	DT_ANGLE	NOT NULL

	, syn_bend_co	DECIMAL(5,2)	NOT NULL	DEFAULT 0.7
	, opp_bend_co	DECIMAL(5,2)	NOT NULL	DEFAULT 0.3
	, mfd_mis_co	DECIMAL(5,2)	NOT NULL	DEFAULT 0
	, bts		TIMESTAMPTZ	NOT NULL	DEFAULT CURRENT_TIMESTAMP
);

INSERT INTO fs_param (
