CREATE TABLE password_reset (
		id SERIAL,
		uid uuid DEFAULT  uuid_generate_v4(),
		username VARCHAR(35) NOT NULL ,
		status INT DEFAULT 0,
		added timestamp without time zone DEFAULT now(),
		updated timestamp without time zone DEFAULT now()
	);
 ALTER TABLE ONLY password_reset
    ADD CONSTRAINT password_reset_id_key UNIQUE (id);


CREATE TABLE members_pending (
		id SERIAL,
		uid uuid DEFAULT  uuid_generate_v4(),
		firstname VARCHAR(35)  NOT NULL,
		lastname VARCHAR(35)  NOT NULL,
		email VARCHAR(35) NOT NULL ,
		status INT DEFAULT 0,
		added timestamp without time zone DEFAULT now(),
		updated timestamp without time zone DEFAULT now()
	);
 ALTER TABLE ONLY members_pending
    ADD CONSTRAINT members_pending_id_key UNIQUE (id);



CREATE TABLE members (
		id SERIAL,
		uid uuid DEFAULT  uuid_generate_v4(),
		username VARCHAR(25) UNIQUE NOT NULL,
		password VARCHAR(250)  NOT NULL,
		loc INET,
		status INT DEFAULT 0,
		added timestamp without time zone DEFAULT now(),
		updated timestamp without time zone DEFAULT now()
	);
 ALTER TABLE ONLY members
    ADD CONSTRAINT members_id_key UNIQUE (id);

ALTER TABLE members ADD email VARCHAR(100);
ALTER TABLE members ADD account_name VARCHAR(100);
ALTER TABLE members ADD firstname VARCHAR(25);
ALTER TABLE members ADD lastname VARCHAR(25);
 ALTER TABLE members ALTER COLUMN password TYPE VARCHAR(250);
ALTER TABLE members ADD country VARCHAR(3);

-- UPDATE members SET account_name ='This is the account name';
-- UPDATE members SET firstname ='Firstname';
-- UPDATE members SET lastname ='Lastname';


CREATE TABLE members_session(
	id SERIAL,
	uid uuid DEFAULT  uuid_generate_v4(),
	member_id INT REFERENCES members(id),
	session_id VARCHAR(100) UNIQUE NOT NULL,
	loc INET,
	status INT DEFAULT 0,
	added timestamp without time zone DEFAULT now(),
	updated timestamp without time zone DEFAULT now()
);

ALTER TABLE ONLY members_session
    ADD CONSTRAINT members_session_id_key UNIQUE (id);



CREATE TABLE products (
		id SERIAL,
		uid uuid DEFAULT  uuid_generate_v4(),
		product_id VARCHAR(25) UNIQUE NOT NULL,
		name VARCHAR(100) UNIQUE NOT NULL,
		description VARCHAR(250)  NOT NULL,
		status INT DEFAULT 0,

		added timestamp without time zone DEFAULT now(),
		updated timestamp without time zone DEFAULT now()
	);
 ALTER TABLE ONLY products
    ADD CONSTRAINT products_id_key UNIQUE (id);

 ALTER TABLE products ADD banner VARCHAR(100);
 UPDATE products set banner  =  'p'||id||'.jpg'


 CREATE TABLE products_details (
		id SERIAL,
		product_id VARCHAR(25) UNIQUE REFERENCES products(product_id),
		details TEXT,
        sale_text TEXT,
		added timestamp without time zone DEFAULT now()
	);
 ALTER TABLE ONLY products_details
    ADD CONSTRAINT products_details_id_key UNIQUE (id);

CREATE TABLE member_product_refresh(
	id SERIAL,
	uid uuid DEFAULT  uuid_generate_v4(),
	member_id INT REFERENCES members(id),
	product_id VARCHAR(25)  NOT NULL,
	subscription_uid VARCHAR(100)  NOT NULL,
	status INT DEFAULT 0,
	added timestamp without time zone DEFAULT now(),
	updated timestamp without time zone DEFAULT now()
);

ALTER TABLE ONLY member_product_refresh
    ADD CONSTRAINT member_product_refresh_id_key UNIQUE (id);




ALTER TABLE products_details OWNER TO merms_panel;

--- ALTER TABLE products_details ADD sale_text TEXT;

INSERT INTO products_details  (product_id,details) VALUES(
'A000002',
'
A Professional Website service utilizing AI tools offers a comprehensive solution for individuals and businesses looking to establish a robust online presence. Here are some key features typically included in such a service:

1. **AI-Powered Design**: The service often employs AI algorithms to help create aesthetically pleasing and user-friendly designs. Users can enter their preferences and the tools will generate layout suggestions, color schemes, and typography that best match their brand identity.

2. **Content Generation**: With AI-driven content creation tools, users can receive assistance in writing engaging website copy, blog posts, and product descriptions. These tools can analyze successful content in similar industries and generate text that aligns with SEO best practices.

3. **SEO Optimization**: AI tools can help optimize websites for search engines by analyzing keywords, providing suggestions for improving visibility, and optimizing site architecture. This ensures that the website ranks well and attracts organic traffic.

4. **Chatbots for Customer Engagement**: Implementing AI chatbots allows businesses to provide instant support to visitors. These bots can answer common questions, guide users through the website, and enhance the overall customer experience.

5. **Analytics and Insights**: Advanced AI analytics can track user behavior, providing insights into how visitors interact with the site. This data helps businesses make informed decisions on improvements and marketing strategies.

6. **Personalization**: Using AI, websites can personalize user experiences based on behavior and preferences. This could include tailored recommendations, customized content, and targeted marketing campaigns that increase engagement.

7. **E-commerce Solutions**: For those looking to sell online, AI tools can optimize the shopping experience by providing product recommendations, personalized discounts, and streamlined check-out processes.

8. **Maintenance and Support**: Many services offer ongoing support and automatic updates using AI to monitor site performance, ensuring that the website runs smoothly and is protected against threats. By leveraging these AI tools, the Professional Website service can deliver not only visually appealing and functional websites but also enhance user engagement, improve operational efficiency, and drive growth for businesses.
'
);

UPDATE products_details SET sale_text =
'<br>
<hr>
Get started for free for 6 months, and add features to your product as needed. cancel anytime
<hr>
<br>';



CREATE TABLE members_products (
		id SERIAL,
		uid uuid DEFAULT  uuid_generate_v4(),
		member_id INT REFERENCES members(id),
		product_id VARCHAR(25) REFERENCES products(product_id),
		internal_url VARCHAR(100) UNIQUE NOT NULL,
		external_url VARCHAR(100),
		dns_group VARCHAR(20),
		status INT DEFAULT 0,
		added timestamp without time zone DEFAULT now(),
		updated timestamp without time zone DEFAULT now()
	);
 ALTER TABLE ONLY members_products
    ADD CONSTRAINT members_products_id_key UNIQUE (id);

ALTER TABLE members_products
ADD CONSTRAINT members_products_unique_member_key
UNIQUE (member_id, product_id);

ALTER TABLE  members_products ADD provision_port INT DEFAULT 0;
ALTER TABLE  members_products ADD primary_server VARCHAR(100);
ALTER TABLE  members_products ADD db_status INT DEFAULT 0;
ALTER TABLE  members_products ADD provision_status INT DEFAULT 0;
ALTER TABLE  members_products ADD p_file INT DEFAULT 0;
ALTER TABLE  members_products ADD url_status INT DEFAULT 0


-- INSERT INTO merms_products (name,description,status,product_id, banner) VALUES ('Personal Website','Your personal professional web presence',1,'A000001', 'banner.jpg');
-- INSERT INTO merms_products (name,description,status,product_id, banner) VALUES ('Professional Website','Your healthcare practice online presence ',1,'A000002', 'banner.jpg');
-- INSERT INTO merms_products (name,description,status,product_id, banner) VALUES ('Personal Blog','Blog to share your health care view',1,'A000003', 'banner.jpg');
-- INSERT INTO merms_products (name,description,status,product_id, banner) VALUES ('Professional Blog','Booster your practice with engaging contents',1,'A000004', 'banner.jpg');
-- INSERT INTO merms_products (name,description,status,product_id, banner) VALUES ('Practice EMR','Get Open EMR for practice management',1,'A000005', 'banner.jpg');

INSERT INTO products (name,description,status,product_id, banner) VALUES ('Personal Website','Your personal professional web presence',1,'A000001', 'banner.jpg');
INSERT INTO products (name,description,status,product_id, banner) VALUES ('Professional Website','Your healthcare practice online presence ',1,'A000002', 'banner.jpg');
INSERT INTO products (name,description,status,product_id, banner) VALUES ('Personal Blog','Blog to share your health care view',1,'A000003', 'banner.jpg');
INSERT INTO products (name,description,status,product_id, banner) VALUES ('Professional Blog','Booster your practice with engaging contents',1,'A000004', 'banner.jpg');
INSERT INTO products (name,description,status,product_id, banner) VALUES ('Practice EMR','Get Open EMR for practice management',1,'A000005', 'banner.jpg');


CREATE TABLE members_products_settings (
		id SERIAL,
		uid uuid DEFAULT  uuid_generate_v4(),
		member_id INT REFERENCES members(id),
        subscription_uid VARCHAR(150),
		product_id VARCHAR(25) REFERENCES products(product_id),
		settings_key VARCHAR(100) NOT NULL,
		setting_type VARCHAR(15) NOT NULL,
		setting_value TEXT,
		status INT DEFAULT 0,
		added timestamp without time zone DEFAULT now(),
		updated timestamp without time zone DEFAULT now()
	);
 ALTER TABLE ONLY members_products_settings
    ADD CONSTRAINT members_products_settings_id_key UNIQUE (id);

ALTER TABLE members_products_settings
ADD CONSTRAINT members_products_settings_unique_member_key
UNIQUE (member_id, product_id, settings_key);

ALTER TABLE members_products_settings OWNER TO merms_panel;
-- member_id,subscription_uid,product_id,settings_key,setting_type,setting_value


CREATE TABLE provision_plans (
		id SERIAL,
		uid uuid DEFAULT  uuid_generate_v4(),
		provision_id INT REFERENCES members_products(id),
		play_file  VARCHAR(100)UNIQUE  NOT NULL,
		msg VARCHAR(100) ,
		added timestamp without time zone DEFAULT now(),
		updated timestamp without time zone DEFAULT now()
	);
 ALTER TABLE ONLY provision_plans
    ADD CONSTRAINT provision_plans_id_key UNIQUE (id);



CREATE TABLE members_external_links (
		id SERIAL,
		uid uuid DEFAULT  uuid_generate_v4(),
		member_id INT REFERENCES members(id),
		member_uid  VARCHAR(100)  NOT NULL,
		facebook VARCHAR(125),
		google VARCHAR(125),
		linkedin VARCHAR(125),
		other_web VARCHAR(125),
		twitter VARCHAR(125),
		added timestamp without time zone DEFAULT now()
	);
 ALTER TABLE ONLY members_external_links
    ADD CONSTRAINT members_external_links_id_key UNIQUE (id);


CREATE TABLE provision_actions (
		id SERIAL,
		uid uuid DEFAULT  uuid_generate_v4(),
		member_id INT REFERENCES members(id),
		product_uid  VARCHAR(100)  NOT NULL,
		action VARCHAR(100)  NOT NULL,
		added timestamp without time zone DEFAULT now()
	);
 ALTER TABLE ONLY provision_actions
    ADD CONSTRAINT provision_actions_id_key UNIQUE (id);

	         {"id": "3", "action": "Verifying your product..." , "date": "10-10-2010 11:00 AM"},
         {"id": "2", "action": "URL assigned - Progress on the URL " , "date": "10-10-2010 11:30 AM"},
         {"id": "1", "action": "Initiating product creation" , "date": "10-12-2010 11:30 AM"},



CREATE TABLE members_actions (
		id SERIAL,
		uid uuid DEFAULT  uuid_generate_v4(),
		member_id INT REFERENCES members(id),
		member_uid  VARCHAR(100)  NOT NULL,
		action_label VARCHAR(35)  NOT NULL,
		action_name  VARCHAR(100)  NOT NULL,
		status_description VARCHAR(25)  NOT NULL,
		status INT DEFAULT 0,
		added timestamp without time zone DEFAULT now(),
		updated timestamp without time zone DEFAULT now()
	);
 ALTER TABLE ONLY members_actions
    ADD CONSTRAINT members_actions_id_key UNIQUE (id);

const insertQuery = 'INSERT INTO ss_subs(members_id, members_uid, action_label,action_name,status_description,status ) VALUES($1, $2, $3, $4, $5, %6)'

      var Querydata = {
            "members_id": req.query.uid,
            "members_uid": req.query.member_id,
            "action_label": 'processing',
			"action_name": 'processing',
            "status_description": req.query.page
			"status": 0
        };
await db.query(insertQuery, Querydata, (err, res) => {
  if (err) {
    console.log(err.stack)
  } else {
    console.log(res.rows[0])

  }


{
    "email": "ameye@chiefsoft.com",
    "firstname": "Olusesan",
    "lastname": "Ameye",
    "isChecked": true
}


CREATE TABLE ttt (
		id SERIAL,
		uid uuid DEFAULT  uuid_generate_v4(),
		username VARCHAR(35) NOT NULL
	);









-- up

ALTER TABLE myoldtable ADD COLUMN newcolumn TEXT;
ALTER TABLE myoldtable ADD CONSTRAINT myoldtable_oldcolumn_newcolumn_key UNIQUE (oldcolumn, newcolumn);

---

ALTER TABLE myoldtable DROP CONSTRAINT myoldtable_oldcolumn_newcolumn_key;
ALTER TABLE myoldtable DROP COLUMN newcolumn;

-- down

merms_panel=# \d products
                                         Table "public.products"
   Column    |            Type             | Collation | Nullable |               Default
-------------+-----------------------------+-----------+----------+--------------------------------------
 id          | integer                     |           | not null | nextval('products_id_seq'::regclass)
 uid         | uuid                        |           |          | uuid_generate_v4()
 product_id  | character varying(25)       |           | not null |
 name        | character varying(100)      |           | not null |
 description | character varying(250)      |           | not null |
 status      | integer                     |           |          | 0
 added       | timestamp without time zone |           |          | now()
 updated     | timestamp without time zone |           |          | now()
 banner      | character varying(100)      |           |          |
Indexes:
    "products_id_key" UNIQUE CONSTRAINT, btree (id)
    "products_name_key" UNIQUE CONSTRAINT, btree (name)
    "products_product_id_key" UNIQUE CONSTRAINT, btree (product_id)



CREATE TABLE products_actions (
		id SERIAL,
		uid uuid DEFAULT  uuid_generate_v4(),
		product_id VARCHAR(25) UNIQUE NOT NULL,
		name VARCHAR(100) UNIQUE NOT NULL,
		description VARCHAR(250)  NOT NULL,
		status INT DEFAULT 0,

		added timestamp without time zone DEFAULT now(),
		updated timestamp without time zone DEFAULT now()
	);
 ALTER TABLE ONLY products_actions
    ADD CONSTRAINT products_actions_id_key UNIQUE (id);



 "name" => "Professional Website",
                "description" => "Your healthcare practice online presence ",
                "status" => 0,
                "product" => 'A000002'





INSERT INTO members (username,email,password)
VALUES
('testaccount','works@chiefsoft.com',md5('merms.user.panel'));

INSERT INTO members (username,email,password)
VALUES
('sanyaameye','works@chiefsoft.com',md5('merms.user.panel'));

INSERT INTO members (username,email,password)
VALUES
('lekanaderibigbe','works@chiefsoft.com',md5('merms.user.panel'));

INSERT INTO members (username,email,password)
VALUES
('kevkemchiro','works@chiefsoft.com',md5('merms.user.panel'));

INSERT INTO members (username,email,password)
VALUES
('icarementalhealth','works@chiefsoft.com',md5('merms.user.panel'));

INSERT INTO members (username,email,password)
VALUES
('kintcare','works@chiefsoft.com',md5('merms.user.panel'));




















su - postgres
createuser merms_panel
createdb merms_panel

psql template1 postgres

alter user merms_panel with encrypted password 'merms_panel';
grant all privileges on database merms_panel to merms_panel;



















