1. Packages
  2. MSSQL
  3. API Docs
  4. Schema
Microsoft SQL Server v0.1.0 published on Tuesday, Oct 8, 2024 by pulumiverse

mssql.Schema

Explore with Pulumi AI

mssql logo
Microsoft SQL Server v0.1.0 published on Tuesday, Oct 8, 2024 by pulumiverse

    Manages single DB schema.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as mssql from "@pulumi/mssql";
    import * as mssql from "@pulumiverse/mssql";
    
    const exampleDatabase = mssql.getDatabase({
        name: "example",
    });
    const owner = mssql.getSqlUser({
        name: "example_user",
    });
    const exampleSchema = new mssql.Schema("exampleSchema", {
        databaseId: exampleDatabase.then(exampleDatabase => exampleDatabase.id),
        ownerId: owner.then(owner => owner.id),
    });
    
    import pulumi
    import pulumi_mssql as mssql
    import pulumiverse_mssql as mssql
    
    example_database = mssql.get_database(name="example")
    owner = mssql.get_sql_user(name="example_user")
    example_schema = mssql.Schema("exampleSchema",
        database_id=example_database.id,
        owner_id=owner.id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    	"github.com/pulumiverse/pulumi-mssql/sdk/go/mssql"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		exampleDatabase, err := mssql.LookupDatabase(ctx, &mssql.LookupDatabaseArgs{
    			Name: "example",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		owner, err := mssql.LookupSqlUser(ctx, &mssql.LookupSqlUserArgs{
    			Name: "example_user",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = mssql.NewSchema(ctx, "exampleSchema", &mssql.SchemaArgs{
    			DatabaseId: pulumi.String(exampleDatabase.Id),
    			OwnerId:    pulumi.String(owner.Id),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Mssql = Pulumi.Mssql;
    using Mssql = Pulumiverse.Mssql;
    
    return await Deployment.RunAsync(() => 
    {
        var exampleDatabase = Mssql.GetDatabase.Invoke(new()
        {
            Name = "example",
        });
    
        var owner = Mssql.GetSqlUser.Invoke(new()
        {
            Name = "example_user",
        });
    
        var exampleSchema = new Mssql.Schema("exampleSchema", new()
        {
            DatabaseId = exampleDatabase.Apply(getDatabaseResult => getDatabaseResult.Id),
            OwnerId = owner.Apply(getSqlUserResult => getSqlUserResult.Id),
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.mssql.MssqlFunctions;
    import com.pulumi.mssql.inputs.GetDatabaseArgs;
    import com.pulumi.mssql.inputs.GetSqlUserArgs;
    import com.pulumi.mssql.Schema;
    import com.pulumi.mssql.SchemaArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            final var exampleDatabase = MssqlFunctions.getDatabase(GetDatabaseArgs.builder()
                .name("example")
                .build());
    
            final var owner = MssqlFunctions.getSqlUser(GetSqlUserArgs.builder()
                .name("example_user")
                .build());
    
            var exampleSchema = new Schema("exampleSchema", SchemaArgs.builder()
                .databaseId(exampleDatabase.applyValue(getDatabaseResult -> getDatabaseResult.id()))
                .ownerId(owner.applyValue(getSqlUserResult -> getSqlUserResult.id()))
                .build());
    
        }
    }
    
    resources:
      exampleSchema:
        type: mssql:Schema
        properties:
          databaseId: ${exampleDatabase.id}
          ownerId: ${owner.id}
    variables:
      exampleDatabase:
        fn::invoke:
          Function: mssql:getDatabase
          Arguments:
            name: example
      owner:
        fn::invoke:
          Function: mssql:getSqlUser
          Arguments:
            name: example_user
    

    Create Schema Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new Schema(name: string, args?: SchemaArgs, opts?: CustomResourceOptions);
    @overload
    def Schema(resource_name: str,
               args: Optional[SchemaArgs] = None,
               opts: Optional[ResourceOptions] = None)
    
    @overload
    def Schema(resource_name: str,
               opts: Optional[ResourceOptions] = None,
               database_id: Optional[str] = None,
               name: Optional[str] = None,
               owner_id: Optional[str] = None)
    func NewSchema(ctx *Context, name string, args *SchemaArgs, opts ...ResourceOption) (*Schema, error)
    public Schema(string name, SchemaArgs? args = null, CustomResourceOptions? opts = null)
    public Schema(String name, SchemaArgs args)
    public Schema(String name, SchemaArgs args, CustomResourceOptions options)
    
    type: mssql:Schema
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args SchemaArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args SchemaArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args SchemaArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args SchemaArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args SchemaArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var schemaResource = new Mssql.Schema("schemaResource", new()
    {
        DatabaseId = "string",
        Name = "string",
        OwnerId = "string",
    });
    
    example, err := mssql.NewSchema(ctx, "schemaResource", &mssql.SchemaArgs{
    	DatabaseId: pulumi.String("string"),
    	Name:       pulumi.String("string"),
    	OwnerId:    pulumi.String("string"),
    })
    
    var schemaResource = new Schema("schemaResource", SchemaArgs.builder()
        .databaseId("string")
        .name("string")
        .ownerId("string")
        .build());
    
    schema_resource = mssql.Schema("schemaResource",
        database_id="string",
        name="string",
        owner_id="string")
    
    const schemaResource = new mssql.Schema("schemaResource", {
        databaseId: "string",
        name: "string",
        ownerId: "string",
    });
    
    type: mssql:Schema
    properties:
        databaseId: string
        name: string
        ownerId: string
    

    Schema Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    The Schema resource accepts the following input properties:

    DatabaseId string
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.
    Name string
    Schema name.
    OwnerId string
    ID of database role or user owning this schema. Can be retrieved using mssql.DatabaseRole, mssql.SqlUser, mssql.AzureadUser or mssql.AzureadServicePrincipal
    DatabaseId string
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.
    Name string
    Schema name.
    OwnerId string
    ID of database role or user owning this schema. Can be retrieved using mssql.DatabaseRole, mssql.SqlUser, mssql.AzureadUser or mssql.AzureadServicePrincipal
    databaseId String
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.
    name String
    Schema name.
    ownerId String
    ID of database role or user owning this schema. Can be retrieved using mssql.DatabaseRole, mssql.SqlUser, mssql.AzureadUser or mssql.AzureadServicePrincipal
    databaseId string
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.
    name string
    Schema name.
    ownerId string
    ID of database role or user owning this schema. Can be retrieved using mssql.DatabaseRole, mssql.SqlUser, mssql.AzureadUser or mssql.AzureadServicePrincipal
    database_id str
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.
    name str
    Schema name.
    owner_id str
    ID of database role or user owning this schema. Can be retrieved using mssql.DatabaseRole, mssql.SqlUser, mssql.AzureadUser or mssql.AzureadServicePrincipal
    databaseId String
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.
    name String
    Schema name.
    ownerId String
    ID of database role or user owning this schema. Can be retrieved using mssql.DatabaseRole, mssql.SqlUser, mssql.AzureadUser or mssql.AzureadServicePrincipal

    Outputs

    All input properties are implicitly available as output properties. Additionally, the Schema resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    Id string
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.
    id string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing Schema Resource

    Get an existing Schema resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: SchemaState, opts?: CustomResourceOptions): Schema
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            database_id: Optional[str] = None,
            name: Optional[str] = None,
            owner_id: Optional[str] = None) -> Schema
    func GetSchema(ctx *Context, name string, id IDInput, state *SchemaState, opts ...ResourceOption) (*Schema, error)
    public static Schema Get(string name, Input<string> id, SchemaState? state, CustomResourceOptions? opts = null)
    public static Schema get(String name, Output<String> id, SchemaState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    DatabaseId string
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.
    Name string
    Schema name.
    OwnerId string
    ID of database role or user owning this schema. Can be retrieved using mssql.DatabaseRole, mssql.SqlUser, mssql.AzureadUser or mssql.AzureadServicePrincipal
    DatabaseId string
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.
    Name string
    Schema name.
    OwnerId string
    ID of database role or user owning this schema. Can be retrieved using mssql.DatabaseRole, mssql.SqlUser, mssql.AzureadUser or mssql.AzureadServicePrincipal
    databaseId String
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.
    name String
    Schema name.
    ownerId String
    ID of database role or user owning this schema. Can be retrieved using mssql.DatabaseRole, mssql.SqlUser, mssql.AzureadUser or mssql.AzureadServicePrincipal
    databaseId string
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.
    name string
    Schema name.
    ownerId string
    ID of database role or user owning this schema. Can be retrieved using mssql.DatabaseRole, mssql.SqlUser, mssql.AzureadUser or mssql.AzureadServicePrincipal
    database_id str
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.
    name str
    Schema name.
    owner_id str
    ID of database role or user owning this schema. Can be retrieved using mssql.DatabaseRole, mssql.SqlUser, mssql.AzureadUser or mssql.AzureadServicePrincipal
    databaseId String
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.
    name String
    Schema name.
    ownerId String
    ID of database role or user owning this schema. Can be retrieved using mssql.DatabaseRole, mssql.SqlUser, mssql.AzureadUser or mssql.AzureadServicePrincipal

    Import

    import using <db_id>/<schema_id> - can be retrieved using SELECT CONCAT(DB_ID(), '/', SCHEMA_ID('<schema_name>'))

    $ pulumi import mssql:index/schema:Schema example '7/5'
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    mssql pulumiverse/pulumi-mssql
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the mssql Terraform Provider.
    mssql logo
    Microsoft SQL Server v0.1.0 published on Tuesday, Oct 8, 2024 by pulumiverse