enable multiple offers per VM node
This commit is contained in:
		
							parent
							
								
									9e3a39545d
								
							
						
					
					
						commit
						9d88cd7cc0
					
				
							
								
								
									
										2
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										2
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							@ -1011,7 +1011,7 @@ dependencies = [
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "detee-shared"
 | 
			
		||||
version = "0.1.0"
 | 
			
		||||
source = "git+ssh://git@gitea.detee.cloud/testnet/proto?branch=credits_app#01e93d3a2e4502c0e8e72026e8a1c55810961815"
 | 
			
		||||
source = "git+ssh://git@gitea.detee.cloud/testnet/proto?branch=offers#4753a17fa29393b3f99b6dfcdcec48d935e6ebd9"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "bincode 2.0.1",
 | 
			
		||||
 "prost",
 | 
			
		||||
 | 
			
		||||
@ -15,7 +15,7 @@ serde_yaml = "0.9.34"
 | 
			
		||||
surrealdb = "2.2.2"
 | 
			
		||||
tokio = { version = "1.44.2", features = ["macros", "rt-multi-thread"] }
 | 
			
		||||
tonic = { version = "0.12", features = ["tls"] }
 | 
			
		||||
detee-shared = { git = "ssh://git@gitea.detee.cloud/testnet/proto", branch = "credits_app" }
 | 
			
		||||
detee-shared = { git = "ssh://git@gitea.detee.cloud/testnet/proto", branch = "offers" }
 | 
			
		||||
ed25519-dalek = "2.1.1"
 | 
			
		||||
bs58 = "0.5.1"
 | 
			
		||||
tokio-stream = "0.1.17"
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										158
									
								
								surql/migration1/final_tables.sql
									
									
									
									
									
										Normal file
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										158
									
								
								surql/migration1/final_tables.sql
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,158 @@
 | 
			
		||||
-- SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
 | 
			
		||||
DEFINE TABLE account SCHEMAFULL;
 | 
			
		||||
DEFINE FIELD balance    ON TABLE account TYPE int    DEFAULT 0;
 | 
			
		||||
DEFINE FIELD tmp_locked ON TABLE account TYPE int    DEFAULT 0;
 | 
			
		||||
DEFINE FIELD escrow     ON TABLE account TYPE int    DEFAULT 0;
 | 
			
		||||
DEFINE FIELD email      ON TABLE account TYPE string DEFAULT "";
 | 
			
		||||
 | 
			
		||||
DEFINE TABLE vm_node SCHEMAFULL;
 | 
			
		||||
DEFINE FIELD operator          ON TABLE vm_node TYPE record<account>;         
 | 
			
		||||
DEFINE FIELD pub_sub_node      ON TABLE vm_node TYPE string default "127.0.0.1:31337";
 | 
			
		||||
DEFINE FIELD country           ON TABLE vm_node TYPE string;                  
 | 
			
		||||
DEFINE FIELD region            ON TABLE vm_node TYPE string;                  
 | 
			
		||||
DEFINE FIELD city              ON TABLE vm_node TYPE string;                  
 | 
			
		||||
DEFINE FIELD ip                ON TABLE vm_node TYPE string;                  
 | 
			
		||||
DEFINE FIELD avail_ipv4        ON TABLE vm_node TYPE int;                     
 | 
			
		||||
DEFINE FIELD avail_ipv6        ON TABLE vm_node TYPE int;                     
 | 
			
		||||
DEFINE FIELD avail_ports       ON TABLE vm_node TYPE int;                     
 | 
			
		||||
DEFINE FIELD max_ports_per_vm  ON TABLE vm_node TYPE int;                     
 | 
			
		||||
DEFINE FIELD connected_at      ON TABLE vm_node TYPE datetime;                
 | 
			
		||||
DEFINE FIELD disconnected_at   ON TABLE vm_node TYPE datetime;                
 | 
			
		||||
 | 
			
		||||
DEFINE TABLE vm_node_offer SCHEMAFULL;
 | 
			
		||||
DEFINE FIELD vm_node    ON TABLE vm_node_offer TYPE record<vm_node>;
 | 
			
		||||
DEFINE FIELD price      ON TABLE vm_node_offer TYPE int;
 | 
			
		||||
DEFINE FIELD vcpus      ON TABLE vm_node_offer TYPE int;
 | 
			
		||||
DEFINE FIELD memory_mib ON TABLE vm_node_offer TYPE int;
 | 
			
		||||
DEFINE FIELD disk_mib   ON TABLE vm_node_offer TYPE int;
 | 
			
		||||
 | 
			
		||||
DEFINE TABLE new_vm_req TYPE RELATION FROM account TO vm_node SCHEMAFULL;
 | 
			
		||||
DEFINE FIELD hostname       ON TABLE new_vm_req TYPE string;
 | 
			
		||||
DEFINE FIELD extra_ports    ON TABLE new_vm_req TYPE array<int>;
 | 
			
		||||
DEFINE FIELD public_ipv4    ON TABLE new_vm_req TYPE bool;
 | 
			
		||||
DEFINE FIELD public_ipv6    ON TABLE new_vm_req TYPE bool;
 | 
			
		||||
DEFINE FIELD disk_size_mib  ON TABLE new_vm_req TYPE int;
 | 
			
		||||
DEFINE FIELD vcpus          ON TABLE new_vm_req TYPE int;
 | 
			
		||||
DEFINE FIELD memory_mib     ON TABLE new_vm_req TYPE int;
 | 
			
		||||
DEFINE FIELD dtrfs_sha      ON TABLE new_vm_req TYPE string;
 | 
			
		||||
DEFINE FIELD dtrfs_url      ON TABLE new_vm_req TYPE string;
 | 
			
		||||
DEFINE FIELD kernel_sha     ON TABLE new_vm_req TYPE string;
 | 
			
		||||
DEFINE FIELD kernel_url     ON TABLE new_vm_req TYPE string;
 | 
			
		||||
DEFINE FIELD created_at     ON TABLE new_vm_req TYPE datetime;
 | 
			
		||||
DEFINE FIELD price_per_unit ON TABLE new_vm_req TYPE int;
 | 
			
		||||
DEFINE FIELD locked_nano    ON TABLE new_vm_req TYPE int;
 | 
			
		||||
DEFINE FIELD error          ON TABLE new_vm_req TYPE string;
 | 
			
		||||
 | 
			
		||||
DEFINE TABLE active_vm TYPE RELATION FROM account TO vm_node SCHEMAFULL;
 | 
			
		||||
DEFINE FIELD hostname       ON TABLE active_vm TYPE string;     
 | 
			
		||||
DEFINE FIELD mapped_ports   ON TABLE active_vm TYPE array<[int, int]>;
 | 
			
		||||
DEFINE FIELD public_ipv4    ON TABLE active_vm TYPE string;     
 | 
			
		||||
DEFINE FIELD public_ipv6    ON TABLE active_vm TYPE string;     
 | 
			
		||||
DEFINE FIELD disk_size_mib  ON TABLE active_vm TYPE int;        
 | 
			
		||||
DEFINE FIELD vcpus          ON TABLE active_vm TYPE int;        
 | 
			
		||||
DEFINE FIELD memory_mib     ON TABLE active_vm TYPE int;        
 | 
			
		||||
DEFINE FIELD dtrfs_sha      ON TABLE active_vm TYPE string;     
 | 
			
		||||
DEFINE FIELD kernel_sha     ON TABLE active_vm TYPE string;     
 | 
			
		||||
DEFINE FIELD created_at     ON TABLE active_vm TYPE datetime;   
 | 
			
		||||
DEFINE FIELD price_per_unit ON TABLE active_vm TYPE int;        
 | 
			
		||||
DEFINE FIELD locked_nano    ON TABLE active_vm TYPE int;        
 | 
			
		||||
DEFINE FIELD collected_at   ON TABLE active_vm TYPE datetime;   
 | 
			
		||||
 | 
			
		||||
DEFINE TABLE update_vm_req TYPE RELATION FROM account TO vm_node SCHEMAFULL;
 | 
			
		||||
DEFINE FIELD vcpus         ON TABLE update_vm_req TYPE int;
 | 
			
		||||
DEFINE FIELD memory_mib    ON TABLE update_vm_req TYPE int;
 | 
			
		||||
DEFINE FIELD disk_size_mib ON TABLE update_vm_req TYPE int;
 | 
			
		||||
DEFINE FIELD dtrfs_sha     ON TABLE update_vm_req TYPE string;
 | 
			
		||||
DEFINE FIELD dtrfs_url     ON TABLE update_vm_req TYPE string;
 | 
			
		||||
DEFINE FIELD kernel_sha    ON TABLE update_vm_req TYPE string;
 | 
			
		||||
DEFINE FIELD kernel_url    ON TABLE update_vm_req TYPE string;
 | 
			
		||||
DEFINE FIELD created_at    ON TABLE update_vm_req TYPE datetime;
 | 
			
		||||
DEFINE FIELD error         ON TABLE update_vm_req TYPE string;
 | 
			
		||||
 | 
			
		||||
DEFINE TABLE deleted_vm TYPE RELATION FROM account TO vm_node SCHEMAFULL;
 | 
			
		||||
DEFINE FIELD hostname       ON TABLE deleted_vm TYPE string;             
 | 
			
		||||
DEFINE FIELD mapped_ports   ON TABLE deleted_vm TYPE array<[int, int]>;  
 | 
			
		||||
DEFINE FIELD public_ipv4    ON TABLE deleted_vm TYPE string;             
 | 
			
		||||
DEFINE FIELD public_ipv6    ON TABLE deleted_vm TYPE string;             
 | 
			
		||||
DEFINE FIELD disk_size_mib  ON TABLE deleted_vm TYPE int;                
 | 
			
		||||
DEFINE FIELD vcpus          ON TABLE deleted_vm TYPE int;                
 | 
			
		||||
DEFINE FIELD memory_mib     ON TABLE deleted_vm TYPE int;                
 | 
			
		||||
DEFINE FIELD dtrfs_sha      ON TABLE deleted_vm TYPE string;             
 | 
			
		||||
DEFINE FIELD kernel_sha     ON TABLE deleted_vm TYPE string;             
 | 
			
		||||
DEFINE FIELD created_at     ON TABLE deleted_vm TYPE datetime;           
 | 
			
		||||
DEFINE FIELD deleted_at     ON TABLE deleted_vm TYPE datetime DEFAULT time::now();
 | 
			
		||||
DEFINE FIELD price_per_unit ON TABLE deleted_vm TYPE int;                
 | 
			
		||||
 | 
			
		||||
DEFINE TABLE app_node SCHEMAFULL;
 | 
			
		||||
DEFINE FIELD operator          ON TABLE app_node TYPE record<account>;         
 | 
			
		||||
DEFINE FIELD pub_sub_node      ON TABLE app_node TYPE string default "127.0.0.1:31337";
 | 
			
		||||
DEFINE FIELD country           ON TABLE app_node TYPE string;                  
 | 
			
		||||
DEFINE FIELD region            ON TABLE app_node TYPE string;                  
 | 
			
		||||
DEFINE FIELD city              ON TABLE app_node TYPE string;                  
 | 
			
		||||
DEFINE FIELD ip                ON TABLE app_node TYPE string;                  
 | 
			
		||||
DEFINE FIELD avail_mem_mib     ON TABLE app_node TYPE int;                     
 | 
			
		||||
DEFINE FIELD avail_vcpus       ON TABLE app_node TYPE int;                     
 | 
			
		||||
DEFINE FIELD avail_storage_mib ON TABLE app_node TYPE int;                     
 | 
			
		||||
DEFINE FIELD avail_ports       ON TABLE app_node TYPE int;                     
 | 
			
		||||
DEFINE FIELD max_ports_per_app ON TABLE app_node TYPE int;                     
 | 
			
		||||
DEFINE FIELD price             ON TABLE app_node TYPE int;                     
 | 
			
		||||
DEFINE FIELD connected_at      ON TABLE app_node TYPE datetime;                
 | 
			
		||||
DEFINE FIELD disconnected_at   ON TABLE app_node TYPE datetime;                
 | 
			
		||||
 | 
			
		||||
DEFINE TABLE new_app_req Type RELATION FROM account to app_node SCHEMAFULL;
 | 
			
		||||
DEFINE FIELD app_name       ON TABLE new_app_req TYPE string;
 | 
			
		||||
DEFINE FIELD package_url    ON TABLE new_app_req TYPE string;
 | 
			
		||||
DEFINE FIELD mr_enclave     ON TABLE new_app_req TYPE string;
 | 
			
		||||
DEFINE FIELD hratls_pubkey  ON TABLE new_app_req TYPE string;
 | 
			
		||||
DEFINE FIELD ports          ON TABLE new_app_req TYPE array<int>;
 | 
			
		||||
DEFINE FIELD memory_mib     ON TABLE new_app_req TYPE int;
 | 
			
		||||
DEFINE FIELD vcpus          ON TABLE new_app_req TYPE int;
 | 
			
		||||
DEFINE FIELD disk_size_mib  ON TABLE new_app_req TYPE int;
 | 
			
		||||
DEFINE FIELD locked_nano    ON TABLE new_app_req TYPE int;
 | 
			
		||||
DEFINE FIELD price_per_unit ON TABLE new_app_req TYPE int;
 | 
			
		||||
DEFINE FIELD error          ON TABLE new_app_req TYPE string;
 | 
			
		||||
DEFINE FIELD created_at     ON TABLE new_app_req TYPE datetime;
 | 
			
		||||
 | 
			
		||||
DEFINE TABLE active_app TYPE RELATION FROM account TO app_node SCHEMAFULL;
 | 
			
		||||
DEFINE FIELD app_name       ON TABLE active_app TYPE string;     
 | 
			
		||||
DEFINE FIELD mapped_ports   ON TABLE active_app TYPE array<[int, int]>;
 | 
			
		||||
DEFINE FIELD host_ipv4      ON TABLE active_app TYPE string;     
 | 
			
		||||
DEFINE FIELD vcpus          ON TABLE active_app TYPE int;        
 | 
			
		||||
DEFINE FIELD memory_mib     ON TABLE active_app TYPE int;        
 | 
			
		||||
DEFINE FIELD disk_size_mib  ON TABLE active_app TYPE int;        
 | 
			
		||||
DEFINE FIELD created_at     ON TABLE active_app TYPE datetime;   
 | 
			
		||||
DEFINE FIELD price_per_unit ON TABLE active_app TYPE int;        
 | 
			
		||||
DEFINE FIELD locked_nano    ON TABLE active_app TYPE int;        
 | 
			
		||||
DEFINE FIELD collected_at   ON TABLE active_app TYPE datetime;   
 | 
			
		||||
DEFINE FIELD mr_enclave     ON TABLE active_app TYPE string;     
 | 
			
		||||
DEFINE FIELD package_url    ON TABLE active_app TYPE string;     
 | 
			
		||||
DEFINE FIELD hratls_pubkey  ON TABLE active_app TYPE string;     
 | 
			
		||||
 | 
			
		||||
DEFINE TABLE deleted_app TYPE RELATION FROM account TO app_node SCHEMAFULL;
 | 
			
		||||
DEFINE FIELD app_name       ON TABLE deleted_app TYPE string;             
 | 
			
		||||
DEFINE FIELD mapped_ports   ON TABLE deleted_app TYPE array<[int, int]>;  
 | 
			
		||||
DEFINE FIELD host_ipv4      ON TABLE deleted_app TYPE string;             
 | 
			
		||||
DEFINE FIELD vcpus          ON TABLE deleted_app TYPE int;                
 | 
			
		||||
DEFINE FIELD memory_mib     ON TABLE deleted_app TYPE int;                
 | 
			
		||||
DEFINE FIELD disk_size_mib  ON TABLE deleted_app TYPE int;                
 | 
			
		||||
DEFINE FIELD created_at     ON TABLE deleted_app TYPE datetime;           
 | 
			
		||||
DEFINE FIELD deleted_at     ON TABLE deleted_app TYPE datetime    DEFAULT time::now();
 | 
			
		||||
DEFINE FIELD price_per_unit ON TABLE deleted_app TYPE int;                
 | 
			
		||||
DEFINE FIELD mr_enclave     ON TABLE deleted_app TYPE string;             
 | 
			
		||||
DEFINE FIELD package_url    ON TABLE deleted_app TYPE string;             
 | 
			
		||||
DEFINE FIELD hratls_pubkey  ON TABLE deleted_app TYPE string;             
 | 
			
		||||
 | 
			
		||||
DEFINE TABLE ban TYPE RELATION FROM account TO account;
 | 
			
		||||
DEFINE FIELD created_at ON TABLE ban TYPE datetime DEFAULT time::now();; 
 | 
			
		||||
 | 
			
		||||
DEFINE TABLE kick TYPE RELATION FROM account TO account;
 | 
			
		||||
DEFINE FIELD created_at ON TABLE kick TYPE datetime;
 | 
			
		||||
DEFINE FIELD reason     ON TABLE kick TYPE string;
 | 
			
		||||
DEFINE FIELD contract   ON TABLE kick TYPE record<deleted_vm|deleted_app>;
 | 
			
		||||
DEFINE FIELD node       ON TABLE kick TYPE record<vm_node|app_node>;
 | 
			
		||||
 | 
			
		||||
DEFINE TABLE report TYPE RELATION FROM account TO vm_node|app_node;
 | 
			
		||||
DEFINE FIELD created_at  ON TABLE report TYPE datetime;
 | 
			
		||||
DEFINE FIELD reason      ON TABLE report TYPE string;
 | 
			
		||||
DEFINE FIELD contract_id ON TABLE report TYPE string;
 | 
			
		||||
							
								
								
									
										13
									
								
								surql/migration1/patch_tables.sql
									
									
									
									
									
										Normal file
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										13
									
								
								surql/migration1/patch_tables.sql
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,13 @@
 | 
			
		||||
-- SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
 | 
			
		||||
REMOVE FIELD price             ON TABLE vm_node;
 | 
			
		||||
REMOVE FIELD avail_vcpus       ON TABLE vm_node;
 | 
			
		||||
REMOVE FIELD avail_storage_mib ON TABLE vm_node;
 | 
			
		||||
REMOVE FIELD avail_mem_mib     ON TABLE vm_node;
 | 
			
		||||
 | 
			
		||||
DEFINE TABLE vm_node_offer SCHEMAFULL;
 | 
			
		||||
DEFINE FIELD vm_node    ON TABLE vm_node_offer TYPE record<vm_node>;
 | 
			
		||||
DEFINE FIELD price      ON TABLE vm_node_offer TYPE int;
 | 
			
		||||
DEFINE FIELD vcpus      ON TABLE vm_node_offer TYPE int;
 | 
			
		||||
DEFINE FIELD memory_mib ON TABLE vm_node_offer TYPE int;
 | 
			
		||||
DEFINE FIELD disk_mib   ON TABLE vm_node_offer TYPE int;
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user